🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #19851

'\n' at start of StringBuffer??

#19851
From: Paul Richards
Date: Tue, 09 Dec 1997 00:00
42 lines
1545 bytes
I'm trying to capture keyboard input and put it into a String so I have 
a number of methods of the form:

 void getName()
    {
      System.out.print( "Enter full name : " );
      sb = new StringBuffer();
      try
      {
        while ( ( c = (char)System.in.read() ) != '\r' )
          sb.append( c );
          name = String.valueOf( sb.toString() );
      }
      catch ( IOException e )
      {
        System.out.println( "IO error" );
        e.printStackTrace();
      }
    } // end getName()
    
where 'name' is a String variable defined as part of my class.
I have a number of other methods such as getAddress1(), getAddress2() 
and getAddress3().

When I look at the variables in the JBuilder debugger I'm getting the 
following:

 name     'aaaaa'
 address1 '\nkkkkkkkkk'
 address2 '\nmmmmmmmmm'
 address3 '\nggggggggg'
 
 I'd have expected '\n' to appear at the *end* of the variable. Can 
anyone explain what is happening?
 
TIA
 ++ *Paul*
 ++ from Cheltenham, England  
 ++ Tue, 09 Dec 1997 19:29 GMT  
 ++ WinNT build 1381 + SP3
 ++ http://freespace.virgin.net/paul.richards/
Technical Details
Message-ID: <VA.00000025.0f60688c@p5>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,8cab8c7f06de7a47,start
X-Google-Attributes: gidf74b3,public
From: Paul Richards <paul.richards@virgin.net>
Subject: '\n' at start of StringBuffer??
Date: 1997/12/09
Message-ID: <VA.00000025.0f60688c@p5>
X-Deja-AN: 296680363
Reply-To: paul.richards@virgin.net
Organization: None
Newsgroups: borland.public.jbuilder.java.language