carriage return in netbeans 5.0

L

Lara

In netbeans 5.0, carriage return results e.g:

System.ou.print("Welcome \rto java");

Welcome
to java

Why???
 
M

Mark Space

Lara said:
In netbeans 5.0, carriage return results e.g:

System.ou.print("Welcome \rto java");

Welcome
to java

Why???

Looks ok to me. What were you expecting?
 
L

Lara

Mark Space ÃÑÓáÊ:
Looks ok to me. What were you expecting?

\r means carriage return not new line
so, the result must be

to java

the cursor will return to the start of current line

another e.g:

System.out.print("Welcome \rjava");

the output:

javaome

but in netbeans 5.0 the output is:

Welcome
java

????
like \n?

????
 
O

Oliver Wong

Lara said:
Mark Space ÃÑÓáÊ:

\r means carriage return not new line
so, the result must be

to java

the cursor will return to the start of current line

another e.g:

System.out.print("Welcome \rjava");

the output:

javaome

but in netbeans 5.0 the output is:

Welcome
java

????
like \n?

????

I suspect the issue is not with NetBeans, but rather with whatever
program (probably some sort of shell, like cmd or bash, or perhaps
NetBean's integrated console) is interpreting the data sent via standard
out.

I'm surprised you know enough to know the "original" meaning of \r,
and yet never experienced the behaviour of treating \n and \r as both a
carriage return followed by a newline until now. Have you been
cryogenically frozen or something?

- Oliver
 
A

Andreas Leitgeb

Lara said:
System.out.print("Welcome \rjava");
the output:
javaome
but in netbeans 5.0 the output is:
Welcome
java

The problem is not, what gets written out to System.out,
but rather how much effort netbeans does to emulate a
real terminal. Obviously this effort does not go far
enough to distinguish between \r and \n.

I just tried with netbeans 5.5: same result.
Then I run the same .jar file from a real
terminal, and I see the expected "javaome".

If you replace the \r with a few \b's, you'll see
that netbeans doesn't even handle backspaces as
such, but instead writes them as white rectangles.
 
L

Lara

I tried netbeans 3.5
the result : javaome
so , it's ok with netbeans 3.5

but netbeans 5.0 , \r dose not do its work...????!!!!!
 
K

Karl Uppiano

Andreas Leitgeb said:
The problem is not, what gets written out to System.out,
but rather how much effort netbeans does to emulate a
real terminal. Obviously this effort does not go far
enough to distinguish between \r and \n.

I'm guessing NetBeans simply uses one of the Swing text controls for its
console output, and it does not emulate a real console at all. I have
noticed that it handles Unicode better than a "real" console, too. I don't
think they really intended it to be a high-fidelity console.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top