-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile8.java
More file actions
32 lines (22 loc) · 837 Bytes
/
Copy pathfile8.java
File metadata and controls
32 lines (22 loc) · 837 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//to read and write a binary files
import java.io.*;
import java.lang.*;
import java.util.*;
class file8
{
public static void main(String arg[]) throws Exception
{
BufferedInputStream in=new BufferedInputStream(new FileInputStream("C:/Users/ABHIJEET/Pictures/Saved Pictures/Ab.jpg"));
BufferedOutputStream out=new BufferedOutputStream(new FileOutputStream("C:/Users/ABHIJEET/Pictures/Saved Pictures/Abhi2.jpg"));
byte buffer[]=new byte[256];
int count=in.read(buffer); //read byte array
while(count>0) //0 if end of file
{
//takes buffer,start index,total elements to be copied
out.write(buffer,0,count);
count=in.read(buffer);
}
out.close();
in.close();
}
}