天天看点

java读取文件(txt)

[img]http://dl2.iteye.com/upload/attachment/0106/8173/3e6f00d3-e34b-3023-bbbe-0019b3aed7c0.jpg[/img]

[size=small][b][color=blue]FileInputStream[/color][/b][/size]

public class FileInputStream extends InputStream

[b]构造方法:[/b]

FileInputStream(File file)

FileInputStream(String name)

FileInputStream(FileDescriptor fdObj)

[size=small][b][color=blue]InputStreamReader[/color][/b][/size]

public class InputStreamReader extends Reader

[b]构造方法:[/b]

InputStreamReader(InputStream in)

InputStreamReader(InputStream in, Charset cs)

InputStreamReader(InputStream in, CharsetDecoder dec)

InputStreamReader(InputStream in, String charsetName)

[color=red]处理的不太完美,一个一个输出的,有待解决[/color]

[size=small][b][color=blue]FileReader[/color][/b][/size]

public class FileReader extends InputStreamReader

[b]构造方法:[/b]

FileReader(File file)

FileReader(FileDescriptor fd)

FileReader(String fileName)

[color=red]乱码问题未解决,有待解决[/color]

[size=small][b][color=blue]BufferedReader[/color][/b][/size][[b][color=green]推荐使用[/color][/b]]

public class BufferedReader extends Reader

[b]构造方法:[/b]

BufferedReader(Reader in)

BufferedReader(Reader in, int sz)