• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Trouble with buffered Reader

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I am trying to read data from a file using a BufferdReader object and then compare it to a String that is determent by args[1] , if it matches i add the data to vector A and if not to vector B , then i write all data in the two vectors to files , this all works nicely and then new file that was not suppose to have the data specivied by args[1] doesn't have any data of it...
so this all works fine, but when is delete the file all data was read from and rename the new file to this file it says it again found that data that i removed, so i am thinking that because it is a BufferedReader the buffers are not cleared , but how can i clear the buffers of a BufferedReader, there is no method called flush() like for a bufferedWriter, does java clear the buffers itself ???
please help here is the read code
public void ReadFile(BufferedReader in, String testText) {
Vector dataBlock = new Vector();
boolean record = false;
String data;
String openBlock = new String("ITEM");
String closeBlock = new String("}");
try {
while ((data = in.readLine()) != null) {
if (openBlock.equalsIgnoreCase(data)) {
record = true;
}
while (record == true) {
data = in.readLine();
dataBlock.addElement(data);
if (closeBlock.equalsIgnoreCase(data)) {
record = false;
this.formatArray(dataBlock, testText);
}
}
}
} catch (IOException e ) {}
}
 
hennie louw
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey all, dont worry, i found the prob
I way closeing and destroying the reffrence to the bufferedReader in the wrong scope
 
reply
    Bookmark Topic Watch Topic
  • New Topic