Advertisement
tcelestino

Função Salva e Abre arquivo

Nov 12th, 2011
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. import java.io.FileReader; import java.io.FileWriter;
  2.  
  3.  
  4. public class arquivo {
  5.    
  6.    public static void gravar(String urlArquivo, String conteudo) throws Exception {
  7.        
  8.        FileWriter pegarConteudo = new FileWriter(urlArquivo, false);
  9.        
  10.        conteudo = "";
  11.  
  12.        pegarConteudo.write(conteudo);
  13.        pegarConteudo.close();  
  14.     }
  15.    
  16.    public static String abrir(String urlArquivo) throws Exception {
  17.        FileReader y = new FileReader(urlArquivo);
  18.        String conteudo = "";          
  19.        int i;
  20.        
  21.        while((i=y.read())!=1) {
  22.            conteudo = conteudo+(char)i;
  23.        }
  24.        y.close();
  25.        
  26.        return conteudo;
  27.    }
  28.    
  29.    
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement