我的配置文件中只有两行, column=50id=10以下是读取配置文件的代码示例。 import java.util.Properties; // 读取属性配置文件的工具类 import org.apache.commons.io.IOUtils; // IO工具类,其中安静的释放对象很好用 public void propertisReader() { Properties propt = null; InputStream is = null; try { is = new FileInputStream("c:/config.properties"); // 根据文件的路径创建输入流 propt = new Properties(); propt.load(is); // 加载配置文件到propt对象中 // 一旦配置文件加载到propt对象中后可以使用getProperty("column") // 这样的方法取得属性值。 String column = propt.getProperty("column"); // 读取属性column的值 String id = propt.getProperty("id"); // 读取属性id的值 System.out.println(id); System.out.println(column); } catch (Exception e) { throw new IllegalArgumentException("加载配置文件失败。",e); } finally { IOUtils.closeQuietly(is); // 安静的释放资源 } }