io- byte input stream -fileinputstream
java.io
Class FileInputStream
public class FileInputStream extends InputStream
FileInputStream Gets the input bytes from a file in the file system. Which files are available depends on the host environment.
The FileInputStream is used to read raw byte streams such as data. To read a character stream, consider using filereader.
22-io- copying pictures -copypic
package day20.io.p2.copypic; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.fileinputstream; import java.io.fileoutputstream; import java.io.ioexception; public class copypictest { private static fileinputstream fis; private static FileOutputStream fos; public static void main (String[] args) throws IOException { copypic4 (); }         PUBLIC STATIC VOID COPYPIC4 () throws Ioexception { //buffer array in the byte stream buffer is possible, you can also use the Flush method, the buffer array of data brush out, The //flush method is valid in the buffer, and if the file is manipulated directly, Fos.flush () is ineffective fis = new fileinputstream ("temp\\0.jpg"); Fos = new fileoutputstream ("temp\\4.jpg"); Bufferedinputstream bufis =new bufferedinputstream (FIS); bufferedoutputstream bufos =new bufferedoutputstream (FOS); byte[] byt = new byte[1024]; while ((Bufis.read (byt))!=-1) { bufos.write (byt); bufos.flush (); &Nbsp; } bufos.close (); bufis.close (); } /*  * COPYPIC3 () This method is not available and is inefficient.      */    PUBLIC STATIC VOID COPYPIC3 () throws ioexception { fis = new FileInputStream ("temp\\0.jpg"); fos = new FileOutputStream ("temp\\3.jpg"); int by = 0; while ((By = fis.read ())!=-1) { fos.write (by);} //disk tunnels running in the same place can be bad. } public static void copypic2 () throws Ioexception { fis = new fileinputstream (" Temp\\0.jpg "); fos = new fileoutputstream (" Temp\ \2.jpg "); bufferedinputstream bufis =new Bufferedinputstream (FIS); bufferedoutputstream bufos =new bufferedoutputstream (FOS); int by = 0; while ((By = bufis.read ())!=-1) { bufos.write (by); } bufos.close (); bufis.close (); } /* * Copy a picture * 1. Both read and write, * 2. or non-text data * both pictures and text, using the word stream */ public static void copypic1 () throws IOException { // 1. Identifying data sources and data purposes Fis = new fileinputstream ("temp\\0.jpg"); fos = new fileoutputstream ("temp\\1.jpg"); //2. Custom Buffers byte[] buf = new byte[1024]; int len = 0; while ((LEN =&NBsp;fis.read (BUF))!=-1) { fos.write (buf, 0,len); } Fos.close (); fis.close (); } }
io-byte input stream-fileinputstream