shango11's Profile User Rating: -----

Reputation: 3 Apprentice
Group:
Active Members
Active Posts:
77 (0.07 per day)
Joined:
06-July 11
Profile Views:
700
Last Active:
User is offline Oct 15 2013 04:45 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   shango11 has not set their status

Posts I've Made

  1. In Topic: renameTo(Folder) always returns false.

    Posted 15 Oct 2013

    View Postg00se, on 15 October 2013 - 03:57 PM, said:

    Probably yes, but it's not clear where your parameters come in with that code


    If that's the only way to get it to work my parameters wouldn't matter so I basically need to find an alternative to the renameTo() function or scrap the whole renaming idea.
  2. In Topic: renameTo(Folder) always returns false.

    Posted 15 Oct 2013

    View Postg00se, on 15 October 2013 - 03:40 PM, said:

    You can't ever really predict it with certainty. Therefore you can't effectively hardcode relative paths. So either use absolute paths or perhaps use File instances got from a JFileChooser


    So I would need to do something like this?
    	public static void renameDirectory(String x, String y)
    	{
    		File filer = new File("C:\\***\\***\\***\\App\\Lab3\\top\\dir1");
    		File filed = new File("C:\\***\\***\\***\\App\\Lab3\\top\\dir11");
    		boolean renamed = filer.renameTo(filed);
    		System.out.println(renamed);
             }
    
    
  3. In Topic: renameTo(Folder) always returns false.

    Posted 15 Oct 2013

    View Postg00se, on 15 October 2013 - 03:15 PM, said:

    OK, so it's a relative path. How do you know from which directory they are going to run your app?

    I do not know from which directory they are going to run the app. It's a school project so I'm guessing they will run the app from the same directory that contain the folder hierarchy mentioned on the first post, otherwise the app won't work.
  4. In Topic: renameTo(Folder) always returns false.

    Posted 15 Oct 2013

    View Postg00se, on 15 October 2013 - 02:59 PM, said:

    Well it's not 'correct' but more about that later. The important thing is that you should be aware the result is unpredictable. And since you append directories to that unpredictable path, that's not (necessarily) going to work.

    What are you intending to be the arguments to the method you wrote?


    I ask the user for the folder name they want to change (so dir1 or dir2 or dir3) and then I ask the user for a new name for the folder (dir11 or dir21 or dir42) and I just try to change the name of the folder. "x" is the original folder name and y is the new folder name.
  5. In Topic: renameTo(Folder) always returns false.

    Posted 15 Oct 2013

    View Postg00se, on 15 October 2013 - 02:44 PM, said:

    A question for you first - what is your intention with this?

    Quote

    String file = new File("").getAbsolutePath();
    


    I use it so I don't have to type out the full path every time. I used it on a couple of functions on the same program and it seemed to help so I thought it would be a good idea to keep using it throughout. Is that the cause of the failed rewriting?

My Information

Member Title:
D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

shango11 hasn't added any friends yet.

Comments

shango11 has no profile comments yet. Why not say hello?