import java.io.{FileInputStream, FileOutputStream}import java.util.Propertiesobject Properties { def main(args: Array[String]): Unit = { val props: Properties =new Properties() val stream: FileInputStream =new FileInputStream("sample.properties") //读取配置文件 props.load(stream) props.list(System.out) //设置key props.setProperty("name","Tom") //获取value println(props.getProperty("log4j.rootCategory")) println(props.getProperty("pwd")) //配置输出 props.store(new FileOutputStream("properties.properties"), "stores") props.storeToXML(new FileOutputStream("properties.xml"), "storeToXML") }}