The byte stream copies an image and the byte stream copies the image.
1. Use Word throttling to read objects and associate images
2. Write stream objects with word throttling and create an image file.
3. Data Storage is completed through cyclic read/write.
4. Disable Resources
Instance code:
import java.io.*;class CopyPic { public static void main(String[] args) { FileOutputStream fos = null; FileInputStream fis = null; try { fos = new FileOutputStream("c:\\2.jpg"); fis = new FileInputStream("c:\\1.jpg"); byte[] buf = new byte[1024]; int len = 0; while((len = fis.read(buf)) != -1){ fos.write(buf, 0 , len); } } catch (IOException e) { throw new RuntimeException("failed!"); } finally{ try { if(fis !=null) fis.close(); } catch (IOException e) { throw new RuntimeException("read failed!"); } try { if(fos !=null) fos.close(); } catch (IOException e) { throw new RuntimeException("write failed!"); } } }}
How Can I copy multiple images in one file?
When you select an image, press Ctrl and select any image you want to select. This is "selected". copy and paste the image.
Finding a basic book on computers can help you learn basic operations easily.
In java, how to use throttling to display the content of a text, and then copy the content to another text
Haha ~~
I also want to join in ~~
Give it to me!
Import java. io. InputStream;
Import java. io. FileInputStream;
Import java. io. OutputStream;
Import java. io. FileOutputStream;
Class Copy {
Public static void main (String args []) {
Try {
InputStream FCM = new FileInputStream ("D:/file1.txt ");
Int size = FCM. available ();
Char [] ch = new char [size];
For (int I = 0; I <size; I ++ ){
Ch [I] = (char) FCM. read ();
}
String str = new String (ch );
System. out. println ("file1.txt file content \ n" + str );
OutputStream fos = new FileOutputStream ("D:/file2.txt ");
Byte [] words = str. getBytes ();
Fos. write (words, 0, words. length );
System. out. println ("\ n file1.txt file has been copied! ");
Fos. close ();
FCM. close ();
}
Catch (IOException ex ){
System. out. println ("the program has an error! ");
}
}
}
Reference: TS117 _ na