Java:Criando um arquivo em Java

From Wiki
Revision as of 17:33, 10 April 2007 by 201.12.4.4 (talk) (New page: Gravando um arquivo em Java import java.io.*; →‎* * @author ebasso: public class GravaArquivo { public static void main(String[] args) { FileOutputStream saida; Prin...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Gravando um arquivo em Java

import java.io.*;

/**
* @author ebasso
*/
public class GravaArquivo {

 public static void main(String[] args) {
   FileOutputStream saida;
   PrintStream fileSaida;
   String sI = "";
   try {
     saida = new FileOutputStream("meuarquivo.txt");
     fileSaida = new PrintStream(saida);

     for (int i = 1; i < 10; i++) {
       sI = String.valueOf(i);
       fileSaida.println(sI);
     }
   }
   catch (Exception e){
     System.err.println(e);
   }
 }
}