Skip to content

Instantly share code, notes, and snippets.

@gwpantazes
Created May 17, 2017 16:08
Show Gist options
  • Save gwpantazes/42492d7ca4bcaed91e8e064e54e19573 to your computer and use it in GitHub Desktop.
Save gwpantazes/42492d7ca4bcaed91e8e064e54e19573 to your computer and use it in GitHub Desktop.
Java Properties with different Separators test
OUTPUT:
value1
value2
value3
value4
import java.io.*;
import java.util.Properties;
class PropertiesDifferentSeparatorsTest
{
public static void main(String[] args) throws FileNotFoundException
{
Properties prop = new Properties();
InputStream input = null;
try {
input = new FileInputStream("/Users/george/Library/Preferences/IdeaIC2017.1/scratches/test.properties");
// load a properties file
prop.load(input);
// get the property value and print it out
System.out.println(prop.getProperty("equals"));
System.out.println(prop.getProperty("equalswithspaces"));
System.out.println(prop.getProperty("justspace"));
System.out.println(prop.getProperty("morespace"));
} catch (IOException ex) {
ex.printStackTrace();
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
equals=value1
equalswithspaces = value2
justspace value3
morespace = value4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment