0
点赞
收藏
分享

微信扫一扫

java读取txt


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();

}

}


举报

相关推荐

0 条评论