Java FileWriter write int to file

Description

Java FileWriter write int to file

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class Main {
  public static void main(String[] args) {
    String path = "Main.txt";
    File file = new File(path);

    try {//ww w . j a va 2  s  .  c om
      FileWriter fw = new FileWriter(file);
      for (int i = 'A'; i <= 'Z'; i++) {
        fw.write(i);
      }
      fw.close();
      System.out.println("Done...");
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
}



PreviousNext

Related