• Post Reply Bookmark Topic Watch Topic
  • New Topic

truncating the first character by bufferedReader

 
Jo Lee
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to read a bolb data from database to a string using the following code:
InputStream bst = rs.getAsciiStream(1);
BufferedReader reader = new BufferedReader(new InputStreamReader(bst));
StringBuffer sbuff = new StringBuffer();
int c;
String longString="";
try{
while ((c = reader.read ()) != -1){
sbuff.append(reader.readLine());
longString = sbuff.toString();

}
System.out.println(longString);
}catch(IOException e){}

When longString is printed out, it prints out all the characters but the very first one? Why?
Jo
 
Jo Lee
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
could any body help please!!
I am lost.
Jo
 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are reading a character (c) and throwing it away, then reading the rest of the line and appending that to the buffer.
[ August 29, 2002: Message edited by: Ron Newman ]
 
Jo Lee
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your help.
I get it sorted now.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!