-2

Ive finished an application and have tested all the functions and they are working. However one part of inputted data is supposed to be saved to a .txt file. Ive placed this inside a string but Im a bit out of my depth in this area and have no idea how to save this to a drive on my PC. Any help is appreciated. The code is on this link: http://sharetext.org/fSy2

1 Answers1

0

Try This:

public static void main(String args[])throws IOException {

  File file = new File("Hello1.txt");
  // creates the file
  file.createNewFile();
  // creates a FileWriter Object
  FileWriter writer = new FileWriter(file); 
  // Writes the content to the file
  writer.write("This\n is\n an\n example\n"); 
  writer.flush();
  writer.close();
}

Read more abut here

Salah
  • 8,567
  • 3
  • 26
  • 43