FileDocCategorySizeDatePackage
LineReaderImpl.javaAPI DocGlassfish v2 API3022Fri May 04 22:25:00 BST 2007com.sun.cli.util

LineReaderImpl

public class LineReaderImpl extends Object implements LineReader

Fields Summary
final InputStreamReader
mInputStreamReader
Constructors Summary
public LineReaderImpl(InputStream inputStream)

		mInputStreamReader	= new InputStreamReader( inputStream );
	
Methods Summary
public java.lang.StringreadLine(java.lang.String prompt)

		final StringBuffer	line	= new StringBuffer();
		
		if ( prompt != null )
		{
			System.out.print( prompt );
		}
		
		while ( true )
		{
			final int	value	= mInputStreamReader.read();
			if ( value < 0 )
			{
				if ( line.length() != 0 )
				{
					// read a line but saw EOF before a newline
					break;
				}
				return( null );
			}
			
			final char	theChar	= (char)value;
			if ( theChar == '\n" )
				break;
			
			line.append( theChar );
		}
		
		return( line.toString().trim() );