62,614
社区成员
发帖
与我相关
我的任务
分享
reader = new BufferedReader(new FileReader(new File(1.txt)));
text.setText("");
String tem;
JTextArea text=new JTextArea();
tem = reader.readLine();
while (tem !=null) {
text.append(tem);
text.append("\n");
tem = reader.readLine();
//if((tem = reader.readLine())!=null)text.append("\n"); 1
}
reader.close();
import java.awt.*;
import java.io.*;
public class Reader {
public static void main(String[] args) {
// TODO Auto-generated method stub
File file = new File("C:/Text.txt");
try {
FileReader fr = new FileReader(file);
BufferedReader bread = new BufferedReader(fr);
String str = null;
while ((str = bread.readLine())!= null)
{
System.out.print(str);
}
bread.close();
fr.close();
}
catch (IOException w) {
}
}
}
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
public class BufferedReaderTest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
BufferedReader reader=null;
try{
reader = new BufferedReader(new FileReader(new File("1.txt")));
StringBuffer tem = new StringBuffer();
String text=new String();
int LEN=1024;
char[] buf = new char[LEN];
int count=0;
while ((count=reader.read(buf,0,LEN))!=-1) {
tem.append(buf,0,count);
}
text=tem.toString();
reader.close();
System.out.print(text);
}catch(Exception ex)
{
}
}
}
reader = new BufferedReader(new FileReader(new File(1.txt)));
text.setText("");
String tem;
JTextArea text=new JTextArea();
tem = reader.readLine();
while (tem !=null) {
text.append(tem);
tem = reader.readLine();
if(tem!=null)text.append("\n");
}
reader.close();