📄 commonproperty.java
字号:
package test.property;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
import test.consts.Messages;
public class CommonProperty {
private static final String inFile =Messages.getString("propertyfile"); //$NON-NLS-1$
private static final String inFile2 =Messages.getString("xmlfile"); //$NON-NLS-1$
public static void main(String[] args) {
boolean propertyToXml=true;
Properties p = new Properties();
File file = new File(inFile);
File file2 = new File(inFile2);
try {
if(propertyToXml){
System.out.println("Property file to Xml file!");
FileInputStream in = new FileInputStream(file);
FileOutputStream out = new FileOutputStream(file2);
p.load(in);
p.storeToXML(out, Messages.getString("ptoxComment")); //$NON-NLS-1$
//PropertyResourceBundle bind = new PropertyResourceBundle(in);
}else{
System.out.println("Xml file to Property file!");
FileInputStream in = new FileInputStream(file2);
FileOutputStream out = new FileOutputStream(file);
p.loadFromXML(in);
p.store(out, Messages.getString("TestConst.xtopComment")); //$NON-NLS-1$
}
System.out.println(p.get("age")); //$NON-NLS-1$
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}//end catch
} // End Main
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -