package com.ok.util;import java.util.*; import java.io.*; /** * <p>Title: OK</p> * <p>Description: For the OK HR bank ^_^</p> * <p>Copyright: Copyright (c) 2004</p> * <p>Company: ok.com.cn</p> * @author apollo * @version 1.0 */public class Untitled1 { public Untitled1() { } public static void main(String[] args) { Untitled1 untitled11 = new Untitled1(); Thread tr=new Thread(); for(;;){ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); try { String cmd = br.readLine(); System.err.println("The command of you input is:"+cmd); tr.sleep(1000); }catch(Exception ie){ ie.printStackTrace(); } } }}
http://dev.csdn.net/article/28/28796.shtm
BufferedReader也有大小限制,怎么办?
那是默认大小的缓冲区,一般来说为8192,你可以在生成对象的时候自定义缓冲区大小。 BufferedReader(Reader in, int sz) Create a buffering character-input stream that uses an input buffer of the specified size. 如果用DataInputStream,也可以用BufferedInputStream。只是在使用的时候自定义缓冲区大小。
import java.io.*;
/**
* <p>Title: OK</p>
* <p>Description: For the OK HR bank ^_^</p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: ok.com.cn</p>
* @author apollo
* @version 1.0
*/public class Untitled1 {
public Untitled1() {
}
public static void main(String[] args) {
Untitled1 untitled11 = new Untitled1();
Thread tr=new Thread();
for(;;){
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
String cmd = br.readLine();
System.err.println("The command of you input is:"+cmd); tr.sleep(1000);
}catch(Exception ie){
ie.printStackTrace();
}
}
}}
BufferedReader(Reader in, int sz)
Create a buffering character-input stream that uses an input buffer of the specified size.
如果用DataInputStream,也可以用BufferedInputStream。只是在使用的时候自定义缓冲区大小。
FileInputStream inputFile;
File newFile=new File(fileName); //通过newFile.length()获得文件大小
BufferedReader bufReader;
inputFile=new FileInputStream(fileName);
bufReader=new BufferedReader( new InputStreamReader(inputFile),150000);
//文件长度是112799,newFile.length()我也用过了,不行。
String strData;
while((strData=bufReader.readLine())!=null)
{
rEditTest.setText(rEditTest.getText()+strData+"\n");
//给richtext赋值,他不会超出大小范围,我试过了
}
这是我的代码,帮忙看看怎么回事。