Advertisement
charleston10

Manipulação de Arquivos

Nov 1st, 2012
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  1.  
  2. import java.io.File;
  3.  
  4. public class Profecia {
  5.     File arquivo = new File("D:\\teste.txt");
  6.     String novo[] = new String[10];
  7.  
  8.     public void verifica_existe() {
  9.         if (!arquivo.exists()) {
  10.             System.out.println("não existe");
  11.         }else{
  12.             System.out.println("existe");
  13.         }
  14.     }
  15.  
  16.     public boolean deleta() {
  17.         arquivo.delete();
  18.         if (!arquivo.delete()) {
  19.             return true;
  20.         }
  21.         return false;
  22.     }
  23.  
  24.     public void dados_arquivo() {
  25.         novo[0] = arquivo.getPath();
  26.         novo[1] = arquivo.getName();
  27.     }
  28.     public void mostra(){    
  29.         System.out.println(novo[0]+"\n"+novo[1]+"\n"+arquivo.length());
  30.     }
  31.  
  32. }
  33. public class Mostra {
  34.  
  35.     public static void main(String[] args) {
  36.      
  37.      Profecia n=new Profecia();
  38.      n.verifica_existe();
  39.      n.dados_arquivo();
  40.      n.mostra();
  41.        }
  42.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement