Reputation: 15
is there a way to save a .txt file in eclipse?
Currently I'm doing:
FileOutputStream fout = new FileOutputStream("C:\\Users\\xxxx\\mytxtfile.txt", false);
I want it to be in the eclipse folder from the project and not an absolute path.
Upvotes: 1
Views: 1936
Reputation: 31
Try the following:
PdfWriter.getInstance(document, newFileOutputStream("C:/Users/xxxx/mytxtfile.txt",false));
Upvotes: 0
Reputation: 1272
try this
FileOutputStream fout = new FileOutputStream("mytxtfile.txt", false);
If you want to use a folder within the project root I recommend this:
File root = new File("yourfolder");
root.mkdir(); //this makes sure the folder exists
File file = new File(root,"mytextfile.txt");
FileOutputStream fout = new FileOutputStream(file, false);
To get the install location of eclipse for eclipse 3.3 (i don't know why you would do this, but still) System.getProperty("eclipse.home.location");
For newer eclipse versions i don't really know.
Upvotes: 2
Reputation: 21748
You can set any initial folder you want in the Eclipse app launch configuration. It is the project root by default but this is not ideal; best is to use some folder like 'run' inside the project that you can add to .gitignore.
Then just empty path (new File("")
) resolves to that folder, and you can also specify sub-path if required.
Upvotes: 1