package org.wu.timer;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Properties;
public class PropertiesDemo {
public static void main(String[] args) {
try {
// System.out.println(System.getProperty("user.dir"));//获取项目的绝对路径
FileInputStream input = new FileInputStream(System.getProperty("user.dir")+File.separator+"eapinfo.ini");
Properties p = new Properties();
// p.load(input);//从输入流中读取属性列表
System.out.println(p.getProperty("eqpt.id"));
System.out.println(p.getProperty("eqpt.type"));
System.out.println(p.getProperty("Port"));
System.out.println(p.getProperty("Driver.T1"));
//-----------------------------------------------------------------------
File file = new File("d:" + File.separator + "hell.txt");
PrintWriter output = new PrintWriter(file);
p.setProperty("你好", "\"Hello\"");
p.list(output);// 将属性列表输出到指定的输出流
output.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
分享到:
相关推荐
import java.util.logging.Logger; public class LoggingDemo { public static void main(String[] args) { Logger logger = Logger.getLogger("pku.sei.LoggingDemo"); if (args.length == 0) { logger....
import java.util.Properties; public class SafeProperties extends Properties { private Charset charset = Charset.forName("UTF-8"); // 设置所需的字符编码 @Override public void load(InputStream in)...
import java.util.Properties; public class PropertiesLoader { public static void main(String[] args) { Properties props = new Properties(); try (InputStream in = PropertiesLoader.class....
import java.util.Properties; public class PropertiesReader { public static void main(String[] args) { try { InputStream in = new FileInputStream("path/to/your/file.properties"); Properties p = ...
import java.util.Properties; public class ReadProperties { public static void main(String[] args) throws Exception { String name = "config.properties"; InputStream in = new FileInputStream(name); ...
使用`java.util.Properties.load()` 这种方法是通过`InputStream`加载一个`Properties`对象,然后使用`load()`方法来读取`Properties`文件中的内容。这种方法适用于任何类型的`InputStream`。 **代码示例:** ``...
import java.util.Properties; public class PropertiesReader { public static void main(String[] args) { Properties prop = new Properties(); FileInputStream ip = null; try { ip = new ...
import java.util.Properties; public class TestProperties { public static void main(String[] args) { // 指定.properties文件的路径 String filePath = "config.properties"; Properties prop = new ...
在Java编程中,资源(Resources)通常指的是应用程序运行所需的外部内容,如配置文件、图像、音频文件等。这些资源通常被嵌入在应用程序的...import java.util.Properties; public class ConfigLoader { public st
import java.util.Properties; public class PropertiesExample { public static void main(String[] args) { String name = "config.properties"; try (InputStream in = new FileInputStream(name)) { ...
import java.util.Properties; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * 现在要求用Java编写一个程序,该程序访问上面的URL,并从页面中, * 提取出上图...
import java.util.regex.Matcher; import java.util.regex.Pattern; /** * . <p/> @author George Wei */ public class I18nTool { private static final String TEMP_RES_ENCODING = "gbk"; private static ...
import java.util.Properties; public class ReadConfigExample { public static void main(String[] args) { // 创建Properties对象 Properties props = new Properties(); try { // 使用当前类的类加载器...
import java.util.Properties; public class PropertiesDemo { public static void main(String[] args) { Properties prop = new Properties(); try { // 加载properties文件 prop.load(new FileInputStream...
import java.util.Properties; public class PropertiesLoad { public static void main(String[] args) throws Exception { String name = "config.properties"; InputStream in = new BufferedInputStream(new...
import java.util.Properties; public class PropertiesReader { public static void main(String[] args) { Properties props = new Properties(); try (InputStream in = PropertiesReader.class....
import java.util.Properties; import javax.mail.Session; import javax.mail.Transport; import javax.mail.Message; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; ...
import java.util.Properties; public class PropertiesExample { public static void main(String[] args) { Properties prop = new Properties(); FileInputStream fis = null; try { fis = new ...
import java.util.Properties; public class PropertiesExample { public static void main(String[] args) { // 创建Properties对象 Properties prop = new Properties(); try { // 打开属性文件 ...
import java.util.Properties; public class DruidJDBCUtils { //定义成员变量 private static DataSource ds; //静态代码块加载配置文件 static { try { Properties prop = new Properties(); ...