collectionwrapper.java

来自「用JAVA实现的小的学生管理系统.JAVA与数据库的结合使用.」· Java 代码 · 共 44 行

JAVA
44
字号
// CollectionWrapper.java - Chapter 16 version.

// Copyright 2000 by Jacquie Barker - all rights reserved.

// An IMPLEMENTATION class.

import java.io.*;

public abstract class CollectionWrapper {
	private String pathToFile;

	public boolean initializeObjects(String pathToFile, boolean primary) {
		this.pathToFile = pathToFile;
		String line = null;
		BufferedReader bIn = null;
		boolean outcome = true;

		try {
			// Open the file. 
			bIn = new BufferedReader(new FileReader(pathToFile));

		    	line = bIn.readLine();
		    	while (line != null) {
			        if (primary) parseData(line);
			        else parseData2(line);
		    		line = bIn.readLine();
			}

			bIn.close();
		}
		catch (FileNotFoundException f) {
			outcome = false;
		}
		catch (IOException i) {
			outcome = false;
		}

		return outcome;
	}

	public abstract void parseData(String line);
	public abstract void parseData2(String line);
}

⌨️ 快捷键说明

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