-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCopyStream.java
More file actions
40 lines (37 loc) · 1.1 KB
/
Copy pathCopyStream.java
File metadata and controls
40 lines (37 loc) · 1.1 KB
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
33
34
35
36
37
38
39
40
package io;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class CopyStream {
void copyByByte(String inputPath, String outputPath) {
try {
InputStream iFile = new FileInputStream(inputPath);
OutputStream oFile = new FileOutputStream(outputPath);
int index=0;
while (true) {
int iEOF = iFile.read();
if (iEOF != -1) {
index++;
oFile.write(iEOF);
System.out.println("index: "+index+" - "+iEOF);
} else {
break;
}
}
iFile.close();
oFile.close();
} catch (IOException ex) {
System.err.println(ex);
}
}
public static void main(String[] args) {
CopyStream cs=new CopyStream();
// String inputFilePath=new String("F:\\git\\learnJava\\etc\\1.txt");
// String outputFilePath=new String("F:\\git\\learnJava\\etc\\2.txt");
String inputFilePath=new String("F:\\git\\learnJava\\etc\\2.PNG");
String outputFilePath=new String("F:\\git\\learnJava\\etc\\3.PNG");
cs.copyByByte(inputFilePath, outputFilePath);
}
}