?? simpleconfig.java
字號:
package javaio;
import java.io.*;
import java.util.*;
public class SimpleConfig
{
public static void main(String[] args)
{
try
{
String fileName=
"D:/Eclipse/eclipse/workspace/config/javaio/Example.conf";
FileInputStream in = new FileInputStream(new File(fileName));
//當文件沒有結束時每次讀取一個字節顯示
String name="";
String value="";
String type="name";
//定義結果Hash表
Hashtable result=new Hashtable();
while (in.available()>0)
{
char c=(char)in.read();
switch(c)
{
case '=':
type="value";
break;
case '\n':
type="name";
result.put(name,value);
name="";
value="";
break;
default:
if(type.equals("name"))
name+=c;
else
value+=c;
}
}
//打印hash表
System.out.println(result);
in.close();
}
catch (IOException e)
{
System.out.println(e.toString());
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -