Results 1 to 3 of 3
  1. #1
    mattgavin is offline Member
    Join Date
    Nov 2010
    Posts
    1
    Rep Power
    0

    Default Reading part of file with BufferedReader

    Hi,

    I'm trying to write a function that grabs a certain part of a file, sends that to another function, then continue to do the same thing from where the BufferedReader left off until the end of the file but can't seem to figure out how to make it work.

    Here is what I have:

    Java Code:
    String str = "";
    int count = 0; 
    		
    	try {
    		while(read through the entire file...){
    			fileReader.reset();
    			while ((count <  4)){	
    				str += fileReader.read();
    				count++;
    			}
    			fileReader.mark(1000);
    		
    			DoSomething(str) // send str to another function and do something with it;
    		}
    		} catch (IOException e) {
    			// TODO Auto-generated catch block
    		}
    Can someone help me with this and explain what I'm doing wrong? Much would be appreciated
    Last edited by mattgavin; 11-12-2010 at 08:35 PM.

  2. #2
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    1st. atleast try to solve your problem (you know exactly what I mean)

    2nd. maybe this Random Access Files (The Java™ Tutorials > Essential Classes > Basic I/O)

  3. #3
    curmudgeon is offline Senior Member
    Join Date
    May 2010
    Posts
    436
    Rep Power
    5

    Default

    Quote Originally Posted by al_Marshy_1981 View Post
    Huh? How does this relate to anything the OP was asking?

Similar Threads

  1. Reading part of a line in a text file
    By aaronfsimons in forum New To Java
    Replies: 3
    Last Post: 05-04-2009, 08:57 AM
  2. Reading a file from Applet (BufferedReader)
    By Java Tip in forum Java Tip
    Replies: 1
    Last Post: 06-22-2008, 11:51 PM
  3. Reading file contents (BufferedReader)
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-07-2008, 10:00 AM
  4. Reading text from a URL using BufferedReader
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-26-2007, 11:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •