就用BufferedInputStream和BufferedOutputStream应该就可以保证效率吧!
如果只考虑效率,不考虑内存使用,可以用ByteArrayInputStream将数据全部
读入到内存,再写出去,值得一试
如果只考虑效率,不考虑内存使用,可以用ByteArrayInputStream将数据全部
读入到内存,再写出去,值得一试
解决方案 »
- 学习编程,切勿浮躁,有想法的请进
- socket 读取数据的问题
- 急求: JTabel 这样的表头怎么做??
- java 图片32位真彩色,灰度级转化方法?
- 讨论下Jtable的一个问题
- 如何看JButton源代码?
- 为什么我在Applet中生成一个Frame类型的窗口,窗口底部总带有Java Applet Window字样,能否去掉
- 我现在要对一组数据排序,这样的情况下,该使用哪种对象啊?Vector还是ArrayList?谢谢
- 一个简单 Applet+线程 程序的问题, 菜鸟求助.
- 小弟在这先谢过了:N天无人搭理my question????
- 在java中,怎么将UTF-8码转换为GB码?
- powerdesigner 和 Rose哪个好用?
{
public static void main(String args[])
{
if(args.length != 2)
{
System.out.println("input: source target");
System.exit(0);
}
String source = args[0];
String target = args[1];
try
{
File newFile = null;
newFile = new File(target);
newFile.createNewFile();
FileInputStream in = new FileInputStream(new File(source));
FileOutputStream out = new FileOutputStream(newFile);
int i = -1;
while(-1 != (i = in.read()))
{
out.write(i);
}
in.close();
out.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
try
{
FileReader fileIn = new FileReader("a.txt") ;
FileWriter fileOut = new FileWriter("b.txt") ;
BufferedReader in = new BufferedReader(fileIn) ;
BufferedWriter out = new BufferedWriter(fileOut) ;
String str ;
while( (str = in.readLine())!=null )
{
out.write(str) ;
}
}
catch( Exception e )
{
System.out.println(e.getMessage()) ;
}
BufferedOuputStream fw = new BufferedOutputStream( new
FileOutputStream("c:\\copy") );
byte[] buf = new byte[8192];
int n;
while((n = fr.read(buf) >= 0))
fw.write(buf,0,n);
fr.close();
fw.close();