<\/span>ReadFromATextFileBufferedReaderClassJava.java<\/span><\/h2>\n\n\n\n\/*\n * How To Read Data From A Text File In Java Using BufferedReader Class.\n * https:\/\/mauricemuteti.info\/how-to-read-data-from-a-text-file-in-java-using-bufferedreader-class\/\n *\/\npackage readfromatextfilebufferedreaderclassjava;\n\nimport java.io.BufferedReader;\nimport java.io.File;\nimport java.io.FileReader;\nimport java.io.IOException;\n\n\/**\n *\n * @author Authentic\n *\/\npublic class ReadFromATextFileBufferedReaderClassJava {\n\n \/**\n * @param args the command line arguments\n *\/\n public static void main(String[] args) {\n \/\/ TODO code application logic here\n\n \/\/Storing File Name In A String Variable.\n String fileName = "textFileData.txt";\n\n \/\/Invoking readFromATextFileBufferedReaderClassJava Method.\n readFromATextFileBufferedReaderClassJava(fileName);\n\n }\n\n \/**\n * readFromATextFileBufferedReaderClassJava Method.\n *\n * Static Method for reading data From A Text File BufferedReader Class In\n * Java.\n *\n * @param fileName\n *\/\n public static void readFromATextFileBufferedReaderClassJava(String fileName) {\n File file = new File(fileName);\n String content;\n int textFileNumberOfLines = 0;\n \/\/Creating FileReader Object.\n FileReader fileReader = null;\n \/\/Creating BufferedReader Object.\n BufferedReader bufferedReader = null;\n try {\n System.out.println("Inside try catch block.");\n fileReader = new FileReader(file);\n bufferedReader = new BufferedReader(fileReader);\n\n System.out.println("Reading From A Text file.");\n while ((content = bufferedReader.readLine()) != null) {\n textFileNumberOfLines++;\n System.out.println("Line " + textFileNumberOfLines + " : " + content);\n }\n System.out.println("Finished Reading From A Text file.");\n } catch (IOException iOException) {\n System.out.println("Error : " + iOException.getMessage());\n } finally {\n\n if (bufferedReader != null) {\n try {\n System.out.println("Closing Buffered Reader Object");\n \/\/Closing Buffered Reader Object\n bufferedReader.close();\n } catch (IOException iOException) {\n System.out.println("Error : " + iOException.getMessage());\n }\n }\n\n if (fileReader != null) {\n try {\n System.out.println("Closing File Reader Object");\n \/\/Closing File Reader Object\n fileReader.close();\n } catch (IOException iOException) {\n System.out.println("Error : " + iOException.getMessage());\n }\n }\n }\n\n }\n}\n<\/pre>\n\n\n\n<\/span>NETBEANS OUTPUT<\/span><\/h2>\n\n\n\nrun:\nInside try catch block.\nReading From A Text file.\nLine 1 : Text File Data\/Content Line 1\nLine 2 : Text File Data\/Content Line 2\nLine 3 : Text File Data\/Content Line 3\nLine 4 : Text File Data\/Content Line 4\nLine 5 : Text File Data\/Content Line 5\nLine 6 : Text File Data\/Content Line 6\nLine 7 : Text File Data\/Content Line 7\nLine 8 : Text File Data\/Content Line 8\nLine 9 : Text File Data\/Content Line 9\nLine 10 : Text File Data\/Content Line 10\nFinished Reading From A Text file.\nClosing Buffered Reader Object\nClosing File Reader Object\nBUILD SUCCESSFUL (total time: 0 seconds)\n\n<\/pre><\/div>\n\n\n<\/span>TEXTFILE DATA<\/span><\/h2>\n\n\n\nText File Data\/Content Line 1\nText File Data\/Content Line 2\nText File Data\/Content Line 3\nText File Data\/Content Line 4\nText File Data\/Content Line 5\nText File Data\/Content Line 6\nText File Data\/Content Line 7\nText File Data\/Content Line 8\nText File Data\/Content Line 9\nText File Data\/Content Line 10\n\n<\/pre><\/div>\n\n\n<\/p>\n\n\n\n
<\/span>SCREENSHOTS<\/span><\/h2>\n\n\n\n <\/figure>\n\n\n\n <\/figure>\n\n\n\n <\/figure>\n\n\n\n <\/figure>\n","protected":false},"excerpt":{"rendered":"How To Read Data From A Text File In Java Using BufferedReader Class. VIDEO TUTORIAL SOURCE CODE ReadFromATextFileBufferedReaderClassJava.java NETBEANS OUTPUT TEXTFILE DATA SCREENSHOTS<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/mauricemuteti.info\/wp-json\/wp\/v2\/posts\/4443"}],"collection":[{"href":"https:\/\/mauricemuteti.info\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mauricemuteti.info\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mauricemuteti.info\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mauricemuteti.info\/wp-json\/wp\/v2\/comments?post=4443"}],"version-history":[{"count":0,"href":"https:\/\/mauricemuteti.info\/wp-json\/wp\/v2\/posts\/4443\/revisions"}],"wp:attachment":[{"href":"https:\/\/mauricemuteti.info\/wp-json\/wp\/v2\/media?parent=4443"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mauricemuteti.info\/wp-json\/wp\/v2\/categories?post=4443"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mauricemuteti.info\/wp-json\/wp\/v2\/tags?post=4443"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}