⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readdatafile.java

📁 java的一系列产品中包括jsme,jmse,j2ee,本文件提供j2ee实现的源代码.
💻 JAVA
字号:
package company;

import java.io.*;
import java.lang.*;
import java.util.*;
 
//JavaBean example1
//JavaBean example2
public class ReadDataFile
{
	private String currentRecord = null;
	private BufferedReader file;
	private String path;
	private StringTokenizer token;
	//创建文件对象
	public ReadDataFile()
	{
		file = new BufferedReader(new InputStreamReader(System.in),1);
		System.out.println("File1 = " + file);
	}
	
	public ReadDataFile(String filePath) throws FileNotFoundException
	{
		path = filePath;
		file = new BufferedReader(new FileReader(path));
		System.out.println("File2 = " + file);
	}
	//设置文件路径
	public void setPath(String filePath)
	{
		path = filePath;
		System.out.println("Path = " + path);
		try
		{
			file = new BufferedReader(new FileReader(path));
		}
		catch (FileNotFoundException e)
		{
			System.out.println("file not found");
		}
	}
	
	//得到文件路径
	public String getPath()
	{
		return path;
	}
	
	//关闭文件
	public void fileClose() throws IOException
	{
		file.close();
	}
	
	//读取下一行记录,若没有则返回-1
	public int nextRecord()
	{
		int returnInt = -1;
		try
		{
			currentRecord = file.readLine();
			System.out.println("currentRecord = " + currentRecord);
		}catch (IOException e)
		{
			System.out.println("readLine problem, terminating.");
		}
		if(currentRecord == null)
			returnInt = -1;
		else
		{
			token = new StringTokenizer(currentRecord);
			returnInt = token.countTokens();
		}
		
		return returnInt;
	}
	
	//以字符串的形式返回整个记录
	public String returnRecord()
	{
		return currentRecord;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -