Case: Copy text files

The analysis is as shown above, the file path is different from the above picture in the code

public  class CopyTxtDemo {
     public  static  void main (String [] args) throws IOException {
         // 1. Create a byte input stream object 
        FileInputStream fis = new FileInputStream ("F: \\ java \\ JavaEE.txt" ) 

        according to the data source ; // 2. Create a byte output stream object 
        FileOutputStream fos = new FileOutputStream ("myFile \\ JavaEE.txt" ); 

        // 3. Read and write data 
        int by;
         while ((by = fis.read ()) ! =-1 ) { 
            fos.write (by); 
        } 

        // 4. Release resources 
        fis.close (); 
        fos.close (); 
    }
}

operation result:

------------>

Guess you like

Origin www.cnblogs.com/pxy-1999/p/12704504.html
Recommended