0

I'm pretty sure someone has already asked this but i Can't find it. How can I write to a text file so that when i build the project from netbeans it'll still be able to write the file when its built into the .jar. I was also having a problem reading file to .jar but found out i could use InputStream and BufferedReader. Is there something that can do this but with writing? This is what I was using:

 printf=new PrintWriter(new File("Names.txt"));

but that doesn't work for writing outside of netbeans. Edit: The file is inside the classes of the jar file that I want to write to.

2 Answers2

0

You can try:

FileOutputStream Output = new FileOutputStram("filename")
FileInputStream Input = new FileInputStream("filename")
James
  • 338
  • 1
  • 2
  • 16
0

Give absolute path like if you want it in d:/someFolder

printf=new PrintWriter(new File("d:/someFolder/Names.txt"));

Please read this

SparkOn
  • 8,806
  • 4
  • 29
  • 34