configreader.java

来自「PhoneBook主要的功能是查找、添加、删除、编辑用户mainclass We」· Java 代码 · 共 41 行

JAVA
41
字号
import java.util.*;
import java.io.*;
import javax.swing.*;


public class ConfigReader{
	private Properties ps;
	private String information;
	
	public ConfigReader(String file){
		ps = new Properties();
		try{
			InputStream in = new FileInputStream(file);
			ps.load(in);
			in.close();
		}
		catch(FileNotFoundException e){
			information = file+"文件未找到!";
		}
		catch(SecurityException e){
			information = file+"文件拒绝访问!";
		}
		catch(IOException e){
			information = "加载"+file+"文件时发生错误!";	
		}
		catch(IllegalArgumentException e){
			information = file+"中包含错误的 Unicode 转义序列!";
		}
		catch(Exception e){
			information = "读取"+file+"文件时发生未知错误!";
		}
		finally{
			if(information!=null)
				JOptionPane.showMessageDialog(null, information, "出错提示", JOptionPane.ERROR_MESSAGE);
		}
	}

	public String get(String arg){
		return (String)ps.get(arg);
	}
}

⌨️ 快捷键说明

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