用java读一个比较大的文本文件(几百k~几M)怎么才能比较快? 如果只是读取,用BufferedReader应该很快. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import java.io.*;public class CopyFile{ 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 = 0; while((i = in.read())!=-1) { out.write(i); } in.close(); out.close(); } catch(Exception e) { e.printStackTrace(); } }}刚才拷贝了一首MP3试了一下,还没有用Buffer 应该是用BufferedInputStreamBufferedReader是基于字符的! javaSE阶段的练习题 用mina2做网络编程,在服务端如何主动发送消息 Java里的Number指的是包装器类型还是基本类型? 新手请教一个关于移位运算的问题 急求分层窗格JLayeredPane的问题 求救!高手帮忙 我想知道java中的jvm和操作系统的关系是什么样的? 目前该用哪种编译器呢? 我用java。awt控件做的 applet在Ie5、ie6为什么不能运行????? 如何修改XML根元素名 请问哪有com.borland.jbcl.layout.*;这个包啊? 求助!!implements的用法与作用,那位大虾可以解释一下???(在线等待)
{
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 = 0;
while((i = in.read())!=-1)
{
out.write(i);
}
in.close();
out.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
刚才拷贝了一首MP3试了一下,还没有用Buffer
BufferedReader是基于字符的!