Re: Inserting Multiple Lines from Console
subhabangalore@gmail.com writes:
If anyone can kindly suggest how may I improve it?
public class Main
{
public void quit(){ java.lang.System.exit( 0 ); }
public void main() throws java.lang.Throwable
{ final javax.script.ScriptEngine scriptEngine
= new javax.script.ScriptEngineManager().getEngineByName( "JavaScript" );
scriptEngine.put( "main", this );
final java.lang.StringBuilder text = new java.lang.StringBuilder();
scriptEngine.put( "text", text );
scriptEngine.eval( "print('');" ); // loads engine for faster reaction
java.lang.System.out.printf
( "*** Texteditor 2000, V1.0 ***%n%n %d Bytes Free%n%n Enter%n%ntext." +
"append('example');%n%n or other StringBuilder calls in JavaScript " +
"syntax to edit,%n%n or enter%n%nmain.quit();%n%n to quit.%n%n",
java.lang.Runtime.getRuntime().freeMemory() );
while( true )try
{ java.lang.System.out.printf( "%n> ", text );
java.lang.System.out.println
( scriptEngine.eval( System.console().readLine() ));
java.lang.System.out.printf( "%s%n", text ); }
catch( final java.lang.Throwable throwable )
{ java.lang.System.err.println( throwable ); }}
public static void main( final java.lang.String[] args )
throws java.lang.Throwable { new Main().main(); }}