Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Francisca Perez   on Mar 25 In Java Category.

  
Question Answered By: Eloise Lawrence   on Mar 25

Try using Properties.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File file  = null;

try {
// read the property text  file
file = new File("o:\\simulator\\myproperty.prop");
FileInputStream fis = new FileInputStream(file);

Properties prop = new Properties();
// feed the property with the file
prop.load(fis);

// Get the application to print out all the key and the value
// of your property file
Enumeration enum = prop.propertyNames();
while (enum.hasMoreElements()) {
String key = (String) enum.nextElement();
String value = (String) prop.get(key);
System.out.println(key + ":" + value);
}
} catch (FileNotFoundException fnfe) {
fnfe.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
}

Share: 

 

This Question has 3 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on search string in text file using JAVA Or get search suggestion and latest updates.


Tagged: