FileTest.java
资源名称:Parsing.rar [点击查看]
上传用户:xiaozhuqw
上传日期:2021-11-10
资源大小:21k
文件大小:1k
源码类别:
词法分析
开发平台:
Java
- import java.io.IOException;
- import java.io.File;
- import java.io.BufferedReader;
- import java.io.FileReader;
- /**
- * <p>Title: </p>
- *
- * <p>Description: </p>
- *
- * <p>Copyright: Copyright (c) 2007</p>
- *
- * <p>Company: </p>
- *
- * @author not attributable
- * @version 1.0
- */
- public class FileTest {
- public StringBuffer buffer;
- public FileTest() {
- buffer = new StringBuffer();
- }
- public void ReadFile(String filename)throws IOException {
- File name = new File(filename);
- if (name.exists()) {
- if (name.isFile()) {
- try {
- BufferedReader input = new BufferedReader(new FileReader(name));
- String text;
- while ((text = input.readLine()) != null) {
- buffer.append(text + "n");
- }
- } catch (IOException e) {
- throw e;
- }//catch
- }//ifname.isFile()
- }//if name exist
- else
- System.out.println("the file is not exist");
- }
- public String getBuffer(){
- return new String(this.buffer);
- }
- }