Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to remove line-termination character after input  RSS feed

 
Ken Ng
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When getting user input,
Pressing Enter terminates user input and sends the input data to the inputstream.
But, it causes a newline to be printed although readline() does not return the line-termination character.

What i want is something like that,
x1 = 2 x2 = 6 x3 = 2 x4 = 2 x5 = 1
But due to line terminator, it becomes like that
x1 = 2
x2 = 6
x3 = 2
x4 = 2
x5 = 1
How can i remove the printed newline or the line-termination characters in the inputstream before sending to standard out?
In general, how to remove printed output?
For example,

Thanks
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's not much you can do with the console in Java. Check out this post
for your alternatives.
 
Tim West
Ranch Hand
Posts: 539
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know this is totally off-topic, but with info from the link provided by Joe, I wrote this class...probably pushing the limits of the Java console ;-) ... it works under Win2K and Cygwin for me

Use is pretty obvious...basically just initialise it with the number of steps you have to make, then call increment() whenever you want...exciting stuff!

-Tim
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!