Java中实现文件拷实例
2008-01-05 20:18:52 来源:WEB开发网核心提示:java中实现文件拷实例import java.io.*; class copy_file { public static void copyfile(String path1,String path2) throws IOException //使用FileInputStream和
java中实现文件拷实例
import java.io.*;
class copy_file
{
public static void copyfile(String path1,String path2) throws IOException //使用FileInputStream和FileOutStream
{
FileInputStream fi=new FileInputStream(path1);
FileOutputStream fo=new FileOutputStream(path2);
byte data[]=new byte[fi.available()];
fi.read(data);
fo.write(data);
fi.close();
fo.close();
}
}
public class joss
{
public static void main(String args[]) throws IOException
{
copy_file.copyfile("f:\\1.jpg","f:\\2.jpg");
}
}
赞助商链接