📄 profile.java
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi
// Source File Name: ProFile.java
package jit.util.jitca.ini;
import java.io.*;
import java.util.HashMap;
import java.util.Set;
// Referenced classes of package jit.util.jitca.ini:
// INIFileLoader
public class ProFile
{
private HashMap content;
private INIFileLoader loader;
public ProFile()
{
content = null;
loader = null;
content = new HashMap();
}
public void load(String filePath)
{
File file = new File(filePath);
if(!file.exists())
try
{
file.createNewFile();
}
catch(Exception ex)
{
System.out.println(ex.toString());
}
loader = new INIFileLoader();
try
{
content = loader.loadIniFromFile(file);
}
catch(Exception ex1)
{
System.out.println(ex1.toString());
}
}
public void load(InputStream ins)
{
loader = new INIFileLoader();
try
{
content = loader.loadIniFromStream(ins);
}
catch(Exception ex)
{
System.out.println(ex.toString());
}
}
public String[] getSections()
{
return convertObj(content.keySet().toArray());
}
public String[] getKeys(String section)
{
if(!isExistsSection(section))
return null;
else
return convertObj(((HashMap)content.get(section)).keySet().toArray());
}
public String getValue(String section, String key)
{
if(!isExistsKey(section, key))
{
return null;
} else
{
String value = (String)((HashMap)content.get(section)).get(key);
return convert(value);
}
}
public void storeValue(String section, String key, String value)
{
if(isExistsSection(section))
{
if(isExistsKey(section, key))
((HashMap)content.get(section)).remove(key);
((HashMap)content.get(section)).put(key, value);
} else
{
createSection(section);
((HashMap)content.get(section)).put(key, value);
}
}
public void writeToFile(String fileName)
throws Exception
{
FileWriter fwriter = new FileWriter(fileName);
String sections[] = getSections();
for(int i = 0; i < sections.length; i++)
{
fwriter.write(String.valueOf(String.valueOf((new StringBuffer("[")).append(sections[i]).append("]"))));
fwriter.write("\n");
String keys[] = getKeys(sections[i]);
if(keys != null)
{
for(int j = 0; j < keys.length; j++)
{
fwriter.write(String.valueOf(String.valueOf((new StringBuffer(String.valueOf(String.valueOf(keys[j])))).append("=").append((String)((HashMap)content.get(sections[i])).get(keys[j])))));
fwriter.write("\n");
}
}
fwriter.write("\n");
}
fwriter.close();
}
public void createSection(String section)
{
content.put(section, new HashMap());
}
public boolean isExistsSection(String section)
{
return content.containsKey(section);
}
public boolean isExistsKey(String section, String key)
{
if(!isExistsSection(section))
return false;
else
return ((HashMap)content.get(section)).containsKey(key);
}
private String[] convertObj(Object obj[])
{
if(obj.length == 0)
return null;
String s[] = new String[obj.length];
for(int i = 0; i < s.length; i++)
s[i] = obj[i].toString();
return s;
}
private String convert(String str)
{
StringBuffer sb = new StringBuffer();
for(int index = -1; (index = str.indexOf(">")) != -1;)
{
sb.append(str.substring(0, index));
str = str.substring(index + 1);
}
sb.append(str);
return sb.toString();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -