aspose file tools*
The moose likes Beginning Java and the fly likes Moving the cursor on the console Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Moving the cursor on the console" Watch "Moving the cursor on the console" New topic
Author

Moving the cursor on the console

Aiman Ashraf
Greenhorn

Joined: Oct 11, 2009
Posts: 5
I am writing a simple console shell. It runs in an infinite loop and expects user to enter commands.

This places the cursor before PROMPT>> not after it. Is there some way to place it after PROMPT>>
This seems tricky because System.in and System.out are different streams.
But it must be simpler than it seems (I hope)
Kalabaw moo
Ranch Hand

Joined: May 26, 2009
Posts: 61
don't have any problem here. You should use .equals() or .equalsIgnoreCase() of the String class if you're going to compare the contents of the String.

Aiman Ashraf
Greenhorn

Joined: Oct 11, 2009
Posts: 5
Yes, you are right.
But that does not solve my original problem. Any ideas?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
Your code unchanged ran all right on my PC, using OpenSUSE 11.1. I had the cursor in the correct place. What sort of terminal are you using?
Aiman Ashraf
Greenhorn

Joined: Oct 11, 2009
Posts: 5
I am testing it on Windows but it will finally run on a *nix machine. So I guess I should be fine. Thanks for the info.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19790
    
  20

On my Windows XP machine it works as you want it, with the cursor after the >>.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
Consider Paul's rocket mass heater.
 
subject: Moving the cursor on the console