propertiesdemo.java

来自「java核心编程的部分源码」· Java 代码 · 共 29 行

JAVA
29
字号
import java.util.*;
import java.io.*;


/**
* Demonstrates how to sort strings.
***/
public class PropertiesDemo
{
public static void main(String args[]) throws Exception
{
Properties props = new Properties();
props.put("db.user", "jack");
props.put("db.password", "opendoor");

// getProperty will return the value if found, otherwise null
System.out.println(props.getProperty("db.user"));

// getProperty will return the value if found, otherwise "none"
System.out.println(props.getProperty("db.password", "none"));

/*
// You can also load properties from a file
FileInputStream fis = new FileInputStream("my.properties");
props.load(fis);
fis.close();
**/
}
} 

⌨️ 快捷键说明

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