public void readDocument(String fileName){
try {
POIFSFileSystem poifs = new POIFSFileSystem(new FileInputStream(fileName));
HWPFDocument doc = new HWPFDocument(poifs);
WordExtractor extractor = new WordExtractor(doc);
String[] paragraphs = extractor.getParagraphText();
for (String paragraph : paragraphs) {
paragraph = paragraph.replaceAll("\\cM?\r?\n", "");
System.out.println(paragraph);
}
} catch (Exception e) {
e.printStackTrace();
}
}
Java Concept
This blog will really helpful to summarize the few Java Related Concept and them real time needs.
Monday, July 26, 2010
Saturday, July 24, 2010
Reading System Environment With JAVA
Map sysEnv = System.getenv();
for (String key : sysEnv.keySet()) {
System.out.println(key +" => "+ sysEnv.get(key));
}
System.getenv(); will return java.util.Map of system environment, which will be easy to iterate as other Map in Java. will be the generic representation of Map
for (String key : sysEnv.keySet()) {
System.out.println(key +" => "+ sysEnv.get(key));
}
System.getenv(); will return java.util.Map
Append Property To System Properties With JAVA
Properties sysProp = System.getProperties();
sysProp.setProperty("country", "India");
System.setProperties(sysProp);
for (String key : sysProp.stringPropertyNames()) {
System.out.println(key +" => "+ sysProp.getProperty(key));
}
appending system property is easy: first get system property and than set new property as pair of key-value.
sysProp.setProperty("country", "India");
System.setProperties(sysProp);
for (String key : sysProp.stringPropertyNames()) {
System.out.println(key +" => "+ sysProp.getProperty(key));
}
appending system property is easy: first get system property and than set new property as pair of key-value.
Subscribe to:
Comments (Atom)