java IO 读写文件_JAVA_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > JAVA > java IO 读写文件

java IO 读写文件

 2011/10/13 8:12:45  361010911  http://hjh5885900.iteye.com  我要评论(0)
  • 摘要:publicclassTest{publicstaticvoidmain(String[]args)throwsThrowable{Filefile=newFile("C:\\Users\\Administrator\\Desktop\\123.jpg");Filefile2=newFile("C:\\Users\\Administrator\\Desktop\\123_4.jpg");System.out.println("Started:")
  • 标签:文件 Java
public class Test {
	public static void main(String[] args) throws Throwable {
		File file = new File("C:\\Users\\Administrator\\Desktop\\123.jpg");
		File file2 = new File("C:\\Users\\Administrator\\Desktop\\123_4.jpg");
		System.out.println("Started:");
		InputStream in = new FileInputStream(file);
		OutputStream out = new FileOutputStream(file2);
		byte[] tempbytes = new byte[1024];
		while (in.available() > 0) {
			int read = in.read(tempbytes, 0, tempbytes.length);
			System.out.println(read);
			out.write(tempbytes, 0, read);
		}
		out.close();
		in.close();
		System.out.println("ended:");
	}
}
?
发表评论
用户名: 匿名