new FileWriter('LPT1:') : FileWriter « java.io « Java by API






new FileWriter('LPT1:')

  
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

public class MainClass {
  public static void main(String[] args) {
    try {
      FileWriter fw = new FileWriter("LPT1:");

      PrintWriter pw = new PrintWriter(fw);
      String s = "www.java2s.com";

      int i, len = s.length();

      for (i = 0; len > 80; i += 80) {
        pw.print(s.substring(i, i + 80));
        pw.print("\r\n");
        len -= 80;
      }

      if (len > 0) {
        pw.print(s.substring(i));
        pw.print("\r\n");
      }

      pw.close();
    } catch (IOException e) {
      System.out.println(e);
    }
  }
}

           
         
    
  








Related examples in the same category

1.new FileWriter(File file)
2.new FileWriter(String string)
3.new FileWriter(String fileName, boolean append)
4.FileWriter: close()
5.FileWriter: flush()
6.FileWriter: write(int i)