Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente bannato
    Registrato dal
    Sep 2012
    Messaggi
    465

    Caccia all'errore

    Oggi mi è successa una cosa stranissima. Ho due file .txt che contengono codici per una classe java Esempio.java. I file sono identici ma Eclipse mi segnala errori solo su uno dei file. Ho letto e riletto il contenuto ma non riesco a vedere differenze e non riesco a vedere errori, sono diventato matto?

    http://dfiles.eu/files/zyyq4wjy5


  2. #2
    Utente di HTML.it L'avatar di Alex'87
    Registrato dal
    Aug 2001
    residenza
    Verona
    Messaggi
    5,802
    Non puoi usare pastebin per condividere il codice?
    SpringSource Certified Spring Professional | Pivotal Certified Enterprise Integration Specialist
    Di questo libro e degli altri (blog personale di recensioni libri) | ​NO M.P. TECNICI

  3. #3
    Utente bannato
    Registrato dal
    Sep 2012
    Messaggi
    465
    codice giusto

    codice:
    /* Copy a text file. 
       To use this program, specify the name 
       of the source file and the destination file. 
       For example, to copy a file called FIRST.TXT 
       to a file called SECOND.TXT, use the following 
       command line. 
     
       java CopyFile FIRST.TXT SECOND.TXT 
    */ 
     
    import java.io.*; 
     
    class Esempio { 
      public static void main(String args[]) throws IOException  
      { 
        int i; 
        FileInputStream fin = null; 
        FileOutputStream fout = null; 
     
        // First, confirm that both files has been specified. 
        if(args.length != 2) { 
          System.out.println("Usage: CopyFile from to"); 
          return; 
        } 
     
        // Copy a File. 
        try { 
          // Attempt to open the files. 
          fin = new FileInputStream(args[0]); 
          fout = new FileOutputStream(args[1]); 
     
          do { 
            i = fin.read(); 
            if(i != -1) fout.write(i); 
          } while(i != -1); 
     
        } catch(IOException e) { 
          System.out.println("I/O Error: " + e); 
        } finally { 
          try { 
            if(fin != null) fin.close(); 
          } catch(IOException e2) { 
            System.out.println("Error Closing Input File"); 
          } 
          try { 
            if(fout != null) fout.close(); 
          } catch(IOException e2) { 
            System.out.println("Error Closing Output File"); 
          } 
        } 
      } 
    }
    codice sbagliato

    codice:
    /* Copy a text file. 
    _ _To use this program, specify the name 
    _ _of the source file and the destination file. 
    _ _For example, to copy a file called FIRST.TXT 
    _ _to a file called SECOND.TXT, use the following 
    _ _command line. 
    
    _ _java CopyFile FIRST.TXT SECOND.TXT 
    */ 
    
    import java.io.*; 
    
    class Esempio { 
    _ public static void main(String args[]) throws IOException_ 
    _ { 
    _ _ int i; 
    _ _ FileInputStream fin = null; 
    _ _ FileOutputStream fout = null; 
    
    _ _ // First, confirm that both files has been specified. 
    _ _ if(args.length != 2) { 
    _ _ _ System.out.println("Usage: CopyFile from to"); 
    _ _ _ return; 
    _ _ } 
    
    _ _ // Copy a File. 
    _ _ try { 
    _ _ _ // Attempt to open the files. 
    _ _ _ fin = new FileInputStream(args[0]); 
    _ _ _ fout = new FileOutputStream(args[1]); 
    
    _ _ _ do { 
    _ _ _ _ i = fin.read(); 
    _ _ _ _ if(i != -1) fout.write(i); 
    _ _ _ } while(i != -1); 
    
    _ _ } catch(IOException e) { 
    _ _ _ System.out.println("I/O Error: " + e); 
    _ _ } finally { 
    _ _ _ try { 
    _ _ _ _ if(fin != null) fin.close(); 
    _ _ _ } catch(IOException e2) { 
    _ _ _ _ System.out.println("Error Closing Input File"); 
    _ _ _ } 
    _ _ _ try { 
    _ _ _ _ if(fout != null) fout.close(); 
    _ _ _ } catch(IOException e2) { 
    _ _ _ _ System.out.println("Error Closing Output File"); 
    _ _ _ } 
    _ _ } 
    _ } 
    }

  4. #4
    Utente bannato
    Registrato dal
    Sep 2012
    Messaggi
    465
    Perché tutti questi trattini nel .txt non li vedo?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.