@Test
public void input() {
String filePath1 = "e:\\tupian.jpg";
String filePath2 = "d:\\tupian.jpg";
FileInputStream fileInputStream = null;
FileOutputStream fileOutputStream = null;
int readLen = 0;
byte[] b = new byte[10240];
try {
fileInputStream = new FileInputStream(filePath1);
fileOutputStream = new FileOutputStream(filePath2);
while ((readLen = fileInputStream.read(b)) != -1) {
fileOutputStream.write(new String(b,0, readLen).getBytes(), 0, readLen);
}
} catch (IOException e) {
e.printStackTrace();
}finally {
try {
fileInputStream.close();
fileOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
@Test
public void input() {
String filePath1 = "e:\\tupian.jpg";
String filePath2 = "d:\\tupian.jpg";
FileInputStream fileInputStream = null;
FileOutputStream fileOutputStream = null;
int readLen = 0;
byte[] b = new byte[10240];
try {
fileInputStream = new FileInputStream(filePath1);
fileOutputStream = new FileOutputStream(filePath2);
while ((readLen = fileInputStream.read(b)) != -1) {
fileOutputStream.write(new String(b,0, readLen).getBytes());
}
} catch (IOException e) {
e.printStackTrace();
}finally {
try {
fileInputStream.close();
fileOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
@Test
public void input() {
String filePath1 = "e:\\tupian.jpg";
String filePath2 = "d:\\tupian.jpg";
FileInputStream fileInputStream = null;
FileOutputStream fileOutputStream = null;
int readLen = 0;
byte[] b = new byte[10240];
try {
fileInputStream = new FileInputStream(filePath1);
fileOutputStream = new FileOutputStream(filePath2);
while ((readLen = fileInputStream.read(b)) != -1) {
fileOutputStream.write(b, 0, readLen);
}
} catch (IOException e) {
e.printStackTrace();
}finally {
try {
fileInputStream.close();
fileOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
只有第三个可以完成复制,不知道前两个错误的原因