title: What is the simplest way to write a text file in Java?
body: <p>I am wondering what is the easiest (and simplest) way to write a text file in Java. Please be simple, because I am a beginner :D</p>
  
  <p>I searched the web and found this code, but I understand 50% of it.</p>
  
  <pre><code>import java.io.BufferedWriter;
  import java.io.File;
  import java.io.FileWriter;
  import java.io.IOException;
  
  public class WriteToFileExample {
  public static void main(String[] args) {
      try {
  
          String content = "This is the content to write into file";
  
          File file = new  File("C:/Users/Geroge/SkyDrive/Documents/inputFile.txt");
  
          // if file doesnt exists, then create it
          if (!file.exists()) {
              file.createNewFile();
          }
  
          FileWriter fw = new FileWriter(file.getAbsoluteFile());
          BufferedWriter bw = new BufferedWriter(fw);
          bw.write(content);
          bw.close();
  
          System.out.println("Done");
  
      } catch (IOException e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>}</p>