java 複製文件

public class copyFIle {code

public static void main(String[] args) throws IOException {xml

File source = new File("d:/test/1.xml");

File des = new File("d:/test/ma.txt");

InputStream input =null;

OutputStream out=new FileOutputStream(des,true);

byte a[]=new byte[10];

try {

	input = new FileInputStream(source);
	
	while((input.read(a))!=-1) {
	
		//容易出錯
		String info=new String(a,0,10);
		
		System.out.println(info);
		
		byte data[]=info.getBytes();
		
	    out.write(data);
		
	    out.flush();
		
		
	}
	out.close();
	
	input.close();
} catch (FileNotFoundException e) {

	
	e.printStackTrace();
}

} }get

相關文章
相關標籤/搜索