1. Open the file with the File class; 2. Create a FileInputStream object using the File object; 3. Convert the FileInputStream to a BufferedInputStream to greatly increase file reading speed; 4. Convert the BufferedInputStream to a DataInputStream; the methods of DataInputStream give a fair amount of flexibility in reading the data. 5. Read the file until the endFile f = new File("mydata.txt"); FileInputStream fis = new FileInputStream(f); BufferedInputStream bis = new BufferedInputStream(fis); DataInputStream dis = new DataInputStream(bis); String record = null; try { while ( (record=dis.readLine()) != null ) { // // put your logic here to work with "record" // } } catch (IOException e) { // // put your error-handling code here // }
From: http://sitestree.com/?p=4775
Categories:Java Short Notes
Tags:
Post Data:2007-12-31 19:48:19
Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada