package com.test.filetest;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
public class FileMain {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
File myfile=new File("H:/test.txt");
//FileReader是字符流,每次读入的是两个字节。
FileReader in=new FileReader(myfile);
BufferedReader br=new BufferedReader(in);
String line=null;
while((line=br.readLine())!=null)
{
System.out.println(line);
}
br.close();
in.close();
}
}
java读取txt
最新推荐文章于 2022-04-23 17:33:43 发布