Results 1 to 2 of 2

Thread: BReader

  1. #1
    Camden is offline Member
    Join Date
    Nov 2007
    Posts
    13
    Rep Power
    0

    Default BReader

    Im adding elements to a Vector (every line of the file has one word or it is empty):

    Java Code:
    ...
    String FileLine;
    while((FileLine = bufferedReader.readLine()) != null) {
                	newVector.add(FileLine);
                	}
    ....
    how can I not include the empty lines that the BufferedReader finds in the txt file?
    Last edited by Camden; 12-01-2007 at 08:49 PM.

  2. #2
    staykovmarin is offline Senior Member
    Join Date
    Nov 2007
    Location
    Newport, WA
    Posts
    141
    Rep Power
    0

    Default

    Java Code:
    	while ((line = rd.readLine()) != null) {
    		if (line.replace(" ", "").length() > 0) vector.add(line);
    	}
    regurgitation: Strips out all the spaces, then checks the length. If > 0 then adds to the vector

Posting Permissions

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