package com.betasoft.test;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class DemoFive {
public static void main(String[] args) {
InputStream is = null;
OutputStream os = null;
try {
File file = new File("D:/a/b.txt");
is = new FileInputStream(file);
os = new FileOutputStream("D:/a.txt");
byte[] b = new byte[is.available()];
//有空格
byte[] b = new byte[1024];
while(is.read(b) != -1){
os.write(b,0,b.length);
}
os.flush();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally{
try {
if(os!=null){
os.close();
}
if(is!=null){
os.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class DemoFive {
public static void main(String[] args) {
InputStream is = null;
OutputStream os = null;
try {
File file = new File("D:/a/b.txt");
is = new FileInputStream(file);
os = new FileOutputStream("D:/a.txt");
byte[] b = new byte[is.available()];
//有空格
byte[] b = new byte[1024];
while(is.read(b) != -1){
os.write(b,0,b.length);
}
os.flush();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally{
try {
if(os!=null){
os.close();
}
if(is!=null){
os.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}