How to debug rename file??

Hi
I use a loop and renameTo() method below to move some files to other location. When I run my class, it should move 5 files (vector include 5 files names), but insteade, some time it move 4 files , some time it move 3 files. there are no error message. Most time, last file cann't be moved
for( int i=0; i<newFiles.size(); i++ ){
File temfile=new File(tempFolder+"/"+newFiles.elementAt(i).toString());
File realfile=new File(destDir+"/"+newFiles.elementAt(i).toString());
boolean successful=temfile.renameTo(realfile);
newFiles is vector to include files name string.
I print out temfile and realfile , all of them are correct. May be somewhere else inside my class, other code, affect this , but I don't how to debug?? Thanks for help
Gary

You can try to catch Exception which could be raise be the methode "renameTo"
try {
boolean successful = temfile.renameTo(realfile);
} catch (Exception e){
System.out.println(e.getMessage());
You can hava SecurityException - If a security manager exists and its SecurityManager.checkWrite(java.io.FileDescriptor) method denies write access to either the old or new pathnames
Bye

Similar Messages

  • HT1473 How do you rename files on a playlist within iTunes? Trying to rename some files from audio CD.  Thanks

    How do you rename files on a playlist in iTunes? Don't see a rename function and want to rename files coming in from audio CD as "track one."  Thanks

    Right-click the track, choose Get Info, and go to the Info tab.  Overtype the Name (and/or any other information that you want to change) with the new information.  Click OK when you are done.

  • How can I rename files without creating a duplicate?

    How can I rename files without creating a duplicate?  And secondly, for some reason I can no longer save pdf files [i.e., bank statements] where I want - the Save As function is gone?

    In many new cases, Save As is now called Duplicate in ML. It uses the same command-S keystroke. Older apps still have Save As. When you do a Duplicate operation, you will create an UNTITLED document. You have to save that duplicated document to complete the process.
    So in 10.6.x, you would do ...
    * Save As ...
    * Give the file a new name + Chose the location for the file
    * Click the Save button
    Now in 10.8.x, you do ...
    * Duplicate ...
    * Save ...
    * Give the file a name + Chose the location for the file
    * Click the Save button
    As baltwo mentioned, you have to search the Preferences of your browser to determine what is has set for the default Download folder.
    JJW

  • How to open renamed files?

    Hi
    I rename selected files and after that want to open them.
    For my purpose renaming works well like this:
    tell application "Finder"
    set FilesToRENAME to selection
    display dialog "Change what?" default answer ""
    set ChangeFROM to text returned of the result
    display dialog "Change to?" default answer ""
    set ChangeTO to text returned of the result
    set AppleScript's text item delimiters to {ChangeFROM}
    set theCount to count of FilesToRENAME
    repeat with x from 1 to theCount
    try
    set theName to name of item x of FilesToRENAME
    set FirstNamePart to first text item of theName
    set LastNamePart to second text item of theName
    set newName to FirstNamePart & ChangeTO & LastNamePart
    set name of item x of FilesToRENAME to newName
    on error errStr number theNumber
    activate
    display dialog "Error in changing the Name " & theNumber & return & errStr ¬
    & return & "Step " & x
    end try
    end repeat
    set AppleScript's text item delimiters to ""
    end tell
    Now newly renamed files don't belong anymore to FilesToRENAME. So how to point to those files now (how to make a new list from those renamed files)? I was thinking to get a path to each file inside the repeat loop and replace the name, but couldn't do it.
    Thank you for any help.
    Vera

    Pierre's method is pretty clever, but if you don't happen to be using a Finder selection (choose file for example), you can also use the interesting fact that an alias keeps track of an item even if it is moved or renamed.
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    font-weight: normal;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px; height: 340px;
    color: #000000;
    background-color: #DAFFB6;
    overflow: auto;"
    title="this text can be pasted into the Script Editor">
    -- tell application "Finder" to set filesToRename to selection as alias list
    set filesToRename to (choose file with multiple selections allowed)
    set changeFrom to text returned of (display dialog "Change what?" default answer "")
    set changeTo to text returned of (display dialog "Change to?" default answer "")
    set renamedFiles to {} -- this will be the renamed files
    repeat with aFile in filesToRename
    set aFile to the contents of aFile
    tell application "Finder" to set theName to name of aFile
    try
    set tempTID to AppleScript's text item delimiters
    set AppleScript's text item delimiters to {changeFrom}
    set firstNamePart to first text item of theName
    set lastNamePart to second text item of theName
    set AppleScript's text item delimiters to tempTID
    set newName to firstNamePart & changeTo & lastNamePart
    tell application "Finder"
    set name of aFile to newName -- aFile points to the original file
    update aFile -- give Finder a chance to catch up
    set the end of renamedFiles to aFile -- aFile now points to the renamed file
    end tell
    on error errStr number theNumber
    activate me
    display alert "Error " & theNumber & " in changing the Name" message errStr
    end try
    end repeat
    renamedFiles --> aliases to the renamed files
    </pre>

  • How to debug swc files in Flash CS5

    Hi, to coin a familiar phrase "I'm new to Flash developement". My question is very simple. How do I debug .swc files (that I've created in Flash Builder 4) in Flash Professional CS5. I've incorporated the .swc file in the Publish Settings->Flash tab. But when I attempt to consume the objects in the .swc file I get an error saying it "Cannot display source code at this location."
    Can someone tell me the best pratice for debugging .swc files. Do I debug them in Flash Builder or Adbobe Professional Flash CS5?

    I think I found the solution to my problem..... but dont know how to implement it correctly.
    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/StageScal eMode.html#SHOW_ALL
    I believe I need to use the SHOW_ALL constant, but there isn't an example of how to do it
    Heres my code, it compiles without errors, but when I publish it as .exe I get the 'Error 1037: Package cannot be nested':
    package
              import flash.display.StageScaleMode
              import flash.media.Camera;
              import flash.media.Video;
              public class ScaleMode
                        public static const SHOW_ALL:String = StageScaleMode.SHOW_ALL;
                        var camera:Camera = Camera.getCamera();
                        if (camera != null) {
                                  videoTwo.attachCamera(camera);
                        } else {
                                  trace("You need a camera.");
              stop();
    Any ideas??

  • How to debug .sda files

    Hi Guys,
    Could anyone tell how to debug the .SDA files.I mean i couldn't found any option to deploy .sda files that i have built through ANT builder in NDS.Till now i am deploying it through SDM only.Is it possible to debug the .SDA files which i am deploying through SDM and debug them through NDS.
    Actually i am trying to debug the Sample Adapter of SAP XI.
    regards,
    Gowtham K.

    Hi Heiko,
      >>>have you tried to start your J2EE engine in debug mode and attached to your server using the debug perspecive and JPDA?
       Yes, i have started J2EE engine in debug mode and from NWDS i kept that application in debug mode.
       But the problem is i am not deploying my .SDA file through NDS.I can only  deploy it through SDM on J2EE server.But the same SDA file i have imported into NDS and set it to debug. But it is not getting debug. Can i deploy .SDA file through NDS.
    regards,
    Gowtham  K.

  • How can I rename files when importing?

    Is there a way to rename files when importing them? Every method I've tried retains the original file name the camera assigns (e.g. DSC_0001). I'd like the ability to rename the files automatically either with a date or event name with sequential numbering following.
    Thanks!

    First you will have to upload from the camera to a folder on the Desktop where you can batch rename them before importing into iPhoto. That's a safer workflow IMO because you can make sure the photos are safely on the hard drive before starting any other operation.
    OT

  • How to move/rename files directly from Premiere 5 ?

    I need to organize better my files, now they are in too many folders and the file name structure is uncorrect.
    Can I manage them directly from Premiere without having to tell the new position as when you do it from out Premiere? just like you can do in Lightroom's library, moving renaming making folders...
    I tried the rename but it only appears different in my project window, the actual filename remains the same..
    Thanks

    It's not an easy thing to do. Many of the video camera formats use very specific folder structures and file naming schemes, particularly those that use more than one file to represent a specific clip--Panasonic P2, for example. To properly maintain expected functionality of the various importers and supported formats, Adobe has to respect those, regardless of how bizarre and labyrinthine they are. They are held hostage to the whims of the camera manufacturers and format consortiums, just as we are. For example, I'm pretty sure that renaming MTS files will break clip spanning, so you have to take responsibility for the loss of that functionality.
    If you don't like it, file a feature request: Adobe Feature Request/Bug Report Form. But just saying something is an "easy task" and that they "just didn't think to do it" is a pretty loaded statement. Let Adobe know what you want, and hope for the best.

  • How do I rename files

    This might be a silly question but on my pc I can right click to get a remane file option.How can I do this on the latest mac book pro?
    Thanks in advance
    J

    CTRL- or RIGHT-click on a file's icon, select Get Info from the contextual menu.  There is a Name and Extension section in which you can rename the file.
    Click on a file's icon then press RETURN to activate the rename option.
    Click in the file icon's name field, pause, click again to activate the rename option.

  • How to debug swf file

    Hi,
    Is there any way to debug the swf file? i am having a swf which is running on different server. i want to debug it from my system. Please let me know if anyone have the solution to debug the swf.
    Thanks
    Thilsen.

    I cannot use firefox since the swf is running in different server.
    that's not correct.
    And integrated with .net application and ruuing in different devices.
    makes no difference.  unless it's an air app or exe, it runs in ff.
    I used to trace but the problem is some times my swf (having multiple scnes) got stuck with unknow reason. Based on the variables which am getting from .net application am navaigating the scnenes.
    trace still can pinpoint the problem.

  • How can i rename files on NTFS external hard drive???

    I cinnected my NTFS external hard drive to my MacBook and i tried to rename some of the files but there wasn't this possibility!I never had a mac before so these is all new to me!The problem is that my external HDD is full and i cannot format it to FAT32! Is there any other solution except using 3rd party applications?Thank you!

    OS X cannot write to an NTFS formatted drive without third-party software to enable the feature. Go to
    MacUpdate or CNET Downloads  and search for NTFS to find alternatives. However, be aware that most will not work compatibly with Lion.

  • How can I rename files based on their ID3 tags?

    For example I would like to rename the files in a particular folder to have the format <track number> - <track name>.mp3
    I'd rather not used third party software to do this.

    For example I would like to rename the files in a particular folder to have the format <track number> - <track name>.mp3
    I'd rather not used third party software to do this.

  • How do I rename many photos all at one time with one click?

    I have got many photos of a sery and want to rename it all with one click only (instead of clicking through it all in single actions and wasting time).
    How can I rename many pictures/photos all together with one click only? -
    1) I have OS X Yosemite
    2) Aperture
    3) Automator App
    to use for this purpose, but I do not see through with any of it.
    Detailed Support for 1) and 2) and 3)  please!
    jona li

    Here is an article on how to batch rename files in Yosemite using just the Finder. This is a new feature in Yosemite. See if this article helps you get your files renamed.

  • Batch rename files on the server?

    Can someone explain how to batch rename files on the server ?
    I have 1000 rows each containing these fields
    id (unique key)
    productCode
    filename1
    filename2
    For every row I need to rename the following fields:
    Rename [filename1] to [productCode]_[id]_1
    Rename [filename2] to [productCode]_[id]_2
    also I need to rename the actual file on the server using the above scheme
    Can someone show me the way ? I'm a little rusty with ColdFusion

    So far I've got everything working apart from CFFILE which works only if it finds a corresponding jpeg file on the server. In other words it works perfectly until row 20 of the database because the filename contained in the field doesn't have a matching jpeg file on the server, so CFFILE fails like this...
    Attribute validation error for tag CFFILE.
    The value of the attribute source, which is currently C:\images\DSCN1293.JPG, is invalid.
    The error occurred in C:\Inetpub\wwwroot\link\htdocs\old_apps\psp\updater.cfm: line 63
    61 :                    action = "rename"
    62 :                    source = #my_source1#
    63 :                    destination = #my_destination1#>
    is there a way to carry on looping through the remaining rows and ignore the above fail ?

  • PS Script To Rename File Using CSV - Filename Is Containing IP Address And Needs To Be Host Name

    Hello All,
    I am currently working with PDF reports which are named "TEMXX.XX.XXX.XX_141215.pdf", XX.XX.XXX.XX is an IP address. I have created a CSV which contains two columns, ColumnA = IPAddress ColumnB = HostName. I would like to remove the existing title
    of the file, and rename it as "ColumnB.pdf".
    The only two commands which come to mind are:
    get-childitem *.pdf | foreach { rename-item $_ $_.Name.Replace("TEM", "") }
    get-childitem *.pdf | foreach { rename-item $_ $_.Name.Replace("_141215", "") }
    The above commands are of course to remove the unwanted "TEM" and "_141215" but I cannot seem to figure out how to just rename files as ColumnB.pdf.
    Any help would be greatly appreciated :).

    Hello All,
    I performed the following but it did not execute, just returned the prompt. The final ps1 file was saved and ran as follows:
    $lines = Import-Csvservers.csv
    ForEach($line in $lines){
    get-childitem *.pdf |where {$_.name -eq $line.ColumnA}|Rename-Item -NewName $line.ColumnB
    CSV file named servers.csv displayed as follows:
    ColumnA,ColumnB
    192.168.1.2,SERVER1
    192.168.1.3,SERVER2
    Files in Explorer displayed as follows:
    ray192.168.1.2_2015.pdf
    ray192.168.1.3_2015.pdf
    As indicated above the filename should be finalized as:
    SERVER1.pdf
    SERVER2.pdf
    Any help in figuring this out would be greatly appreciated.

Maybe you are looking for

  • New P6N Platinum acting wierd...

    What's up guys.  My dad's computer at his office has been giving him problems like locking up, sluggish performance even after a reformat, etc so he gave me $1200 to build him a new machine that will last him "a long time". hahah So I've put together

  • RBE 3.0 Transaction file

    Running RBE3.0 Test version I downloaded the 4 xml-files using ZRBE_MAIN, but there is the Transaction assignment file that seems to be misformatted meaning that TRANSACTION TAG of the XML seems to be missing. File is generated using Abap zrbe_dwl_tr

  • Initialize 2 dimensions arrays

    Hi everybody. Im using Oracle 11g, on Linux Centos. My problem is with 2 dimensions array. I have defined a type in the database in this way : create or replace TYPE ARRAY_N_12 is varray(12) of number; Now I try to do the next : create or replace pro

  • V570 - Clean Install Problems and Some Solutions

    And where is this new bios? I ran into the same problem all these guys mentioned with Windows 7 Ultimate installing on the EFI partition.  The wireless adapter simply does not start.  I only see the bios version 36 uploaded on August 17 which does no

  • Browser not supported after CS4 Install

    I installed CS4 Design Premium today and have been having browser trouble since. I'm getting alerts from multiple websites that state that my browser is not supported or that my system does not meet minimum requirements (veer.com, netflix.com). I hav