import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException;
public class ReadFileExample {
public static void main(String[] args) { BufferedReader objReader = null; try { String strCurrentLine; objReader = new BufferedReader(new FileReader("D:DukesDiary.txt")); while ((strCurrentLine = objReader.readLine()) != null) { System.out.println(strCurrentLine); } } catch (IOException e) { e.printStackTrace(); } finally { try { if (objReader != null) objReader.close(); } catch (IOException ex) { ex.printStackTrace(); } } }
}
hi friend,
Yes, your doubt is genuine this code may not read properly the doc or docx etc. (Microsoft Office suit file format) files. If you tried to read these files it would be seem like a corrupted file.
To know how to read doc file in java you can go through the link
http://www.roseindia.net/tutorial/java/poi/readDocFile.html
Thanks.
Ads