Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
changing directory in java
Name: priti Date: March 5, 2004 at 19:44:41 Pacific OS: WIn 2000 CPU/Ram: P3
Comment:
Hi, I'm writting webserver and I want to change the directory. How can I do this in java? e.g I've working dir. /aaa/bb/t.txt and I want to access fiel in dir /aaa/bc/p.txt How could I do this? Any help will be appreciated? Thanks/
Name: wharfie Date: March 10, 2004 at 15:52:18 Pacific
Reply:
I don't believe the working directory of your Java application can be changed so if it was /aaa/bb when you launched your Java application that is what it will stay.
There is no need to change it to access files in other directories as the java.io.File constructor takes a qualified file name which may include an absolute or relative path.
In the scenario you describe you would create the two files like this
// file in working directory File tFile = new File("t.txt");
// file in another directory using relative path File pFile = new File(".." + File.separator + "bc" + File.separator + "p.txt"0;
// access both files FileInputStream tInputStream = new java.io.FileInputStream(tFile); FileInputStream pInputStream = new java.io.FileInputStream(pFile);
Summary: I had this problem when I first started. This means that java cannot find your bytecode file. (hello.class) As you can see your program hasn't been turned into bytecode. so open the command prompt (...
Summary: I'm writing a program in java to show a phone list. the only things needed are names and numbers. I've got the frame created and two panels, one to show the list, and another to add or remove number...
Summary: in java you have to use two back slashes to create a directory path like so C:\\program\\sub1 and so on because a single slash has a meaning ...