So basically I have this file that my program needs to open called "outfile.txt" and "fort.20.txt". In windows, I have the file located at the root of the C:\\ drive, and the program compiles perfectly. My program goes to the directory like this:

File textfile1 = new File("C:\\outfile.txt");
File textfile2 = new File("C:\\fort.20.txt");

The thing is, my program needs to work on linux as well(Ubuntu specifically). I have a directory on a linux computer called "/home/lcoy" - that is where I would like my files to be stored while running the program on linux. Would I go to the directory just like I did on windows? I imagine it would be something like this:

File textfile1 = new File("/home/lcoy/outfile.txt");
File textfile2 = new File("/home/lcoy/fort.20.txt");

Can someone tell me if this is the proper way to refer to the file directory on a linux system? Thank you for your help.

Recommended Answers

All 2 Replies

Do you have a linux system available?
Compile and test your code there to see what works.

Let us know how you do.

Do you have a linux system available?
Compile and test your code there to see what works.

Let us know how you do.

I have a solaris right here, as a matter of fact. Ill report back when I try it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.