Created
May 17, 2017 16:08
-
-
Save gwpantazes/42492d7ca4bcaed91e8e064e54e19573 to your computer and use it in GitHub Desktop.
Java Properties with different Separators test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OUTPUT: | |
value1 | |
value2 | |
value3 | |
value4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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