而不使用getproperty一个一个的取。最好给个例子。谢谢了!!!
5 个解决方案
#1
import java.util.Enumeration;
import java.util.Properties;
public class Test {
public static void main(String arg[]) {
Properties prop = new Properties();
prop.put(1, "a");
prop.put(2, "b");
Enumeration enums = prop.keys();
while (enums.hasMoreElements()) {
Object key = enums.nextElement();
System.out.println("key = " + key + " value = " + prop.get(key));
}
}
}
import java.util.Properties;
public class Test {
public static void main(String arg[]) {
Properties prop = new Properties();
prop.put(1, "a");
prop.put(2, "b");
Enumeration enums = prop.keys();
while (enums.hasMoreElements()) {
Object key = enums.nextElement();
System.out.println("key = " + key + " value = " + prop.get(key));
}
}
}
#2
给你一sample, 在c盘更目录放一个p.properties文件就可以测试了。
public class TestProperties {
public static void main(String[] args) throws FileNotFoundException, IOException {
Properties p = new Properties();
p.load(new FileInputStream(new File("c:\\p.properties")));
Iterator itr = p.entrySet().iterator();
while (itr.hasNext()){
Entry e = (Entry)itr.next();
System.out.println(e.getKey() + ": " + e.getValue());
}
}
}
#3
very good!
#4
例子很好,非常感谢!
#5
呵呵 还可以老
#1
import java.util.Enumeration;
import java.util.Properties;
public class Test {
public static void main(String arg[]) {
Properties prop = new Properties();
prop.put(1, "a");
prop.put(2, "b");
Enumeration enums = prop.keys();
while (enums.hasMoreElements()) {
Object key = enums.nextElement();
System.out.println("key = " + key + " value = " + prop.get(key));
}
}
}
import java.util.Properties;
public class Test {
public static void main(String arg[]) {
Properties prop = new Properties();
prop.put(1, "a");
prop.put(2, "b");
Enumeration enums = prop.keys();
while (enums.hasMoreElements()) {
Object key = enums.nextElement();
System.out.println("key = " + key + " value = " + prop.get(key));
}
}
}
#2
给你一sample, 在c盘更目录放一个p.properties文件就可以测试了。
public class TestProperties {
public static void main(String[] args) throws FileNotFoundException, IOException {
Properties p = new Properties();
p.load(new FileInputStream(new File("c:\\p.properties")));
Iterator itr = p.entrySet().iterator();
while (itr.hasNext()){
Entry e = (Entry)itr.next();
System.out.println(e.getKey() + ": " + e.getValue());
}
}
}
#3
very good!
#4
例子很好,非常感谢!
#5
呵呵 还可以老