java 代码
- // reads the properties from the property file
- Properties props = new Properties();
- try {
- props.load(new FileInputStream(PROPERTIES_FILE));
- } catch (IOException ex) {
- System.out.println("error configuring unit tests");
- ex.printStackTrace();
- }
- SFTP_HOSTNAME = props.getProperty("server");
- InetAddress temp = null;
- try {
- temp = InetAddress.getByName(SFTP_HOSTNAME);
- } catch (UnknownHostException ex) {
- System.out.println("error resolving host " + SFTP_HOSTNAME);
- }
- SFTP_HOST = temp;
- USERNAME = props.getProperty("username");
- PASSWORD = props.getProperty("password");