-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBinaryFilesCopy.java
More file actions
36 lines (30 loc) · 856 Bytes
/
Copy pathBinaryFilesCopy.java
File metadata and controls
36 lines (30 loc) · 856 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
33
34
35
36
/*This program runs very slow because it copies exactly one byte at a time*/
import java.io.*;
public class CopyFiles
{
public static void main(String[] args)
{
if (args.length < 2)
{
System.out.println("Please provide input and output files");
System.exit(0);
}
String inputFile = args[0];
String outputFile = args[1];
try (
InputStream inputStream = new FileInputStream(inputFile);
OutputStream outputStream = new FileOutputStream(outputFile);
)
{
int byteRead = -1;
while ((byteRead = inputStream.read()) != -1)
{
outputStream.write(byteRead);
}
}
catch (IOException e)
{
e.printStackTrace();
}
}
}