I am trying to find a specific word from list of files and these files can be ASCII, Unicode or some other format. So far I can only work on ASCII files . Is there any way to do same operation with other file encoding formats.
Scanner s = null;
try {
s = new Scanner(new BufferedReader(new FileReader("C:\\New Microsoft Word Document.docx")));
while (s.hasNext()) {
// final String lineFromFile = s.nextLine();
// if(lineFromFile.contains("DE")){
System.out.println(s.next());
// break;
// }
}
} finally {
if (s != null) {
s.close();
}
}
I get the following results
Q[µM¡°‰”Ø÷Þ3{:½¹®’)xTÖä¬?µXFÚB™QÎÞ‡Ïé=K0SˆÊÈÙ?õº×W?áÂ&¤6˜³qî?s”cÐ3ëÀÐJi½?^ýˆ;!¿Äøm«uÇ¥5LHCô`ÝΔbR…¤?§Ï+gF,y\í‹Q9S:êãw~Pá¡Â=‰p®RRª?OM±Ç•®™2R.÷àX9¼!ð#
qe—i;`{¥fzU@2>¼Mä|f}Á
+'šªÎNÛ