• Post Reply Bookmark Topic Watch Topic
  • New Topic

system.in.skip(2) in Netbeans IDE?  RSS feed

 
Nguyen Van Huong
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyon
In my java program, I want to discard 2 characters: \n \r --> I use System.in.skip(2). It worked well in Command Promt, but it failed in Netbean IDE?

Many thanks!
 
Greg Charles
Sheriff
Posts: 3014
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are some differences in how the IDEs implement System.out and especially System.in in order to attach the streams to their console windows. It might also be that the NetBeans console doesn't send CR and LF to mark the end of a line. How does the skip() method fail? With an exception, or just something not working right?

(P.S., is it Hương or Hường?)
 
Nguyen Van Huong
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. I don't understand how the NetBeans works when it sends a character from a client to a server in my program.

And, the result:
Server:

Server is stating...
Có một client nối kết!
Nhận và gởi kí tự a về client
Nhận và gởi kí tự
về client

Client:

Nhập vào một kí tự: a
Kí tự nhận về a
Nhập vào một kí tự: Kí tự nhận về

Nhập vào một kí tự:


(P.S: My full name is Nguyễn Văn Hương. ^^)
 
Greg Charles
Sheriff
Posts: 3014
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, really? Hương is an unusual name for a man, isn't it? (Unless you're a woman with a middle name Văn, which I've never seen before.) Oh, well, when I lived in Viet Nam, I called myself Giang, which is also typically a girl's name. I liked it because of the Gs though.

Anyway, anh Hương, your code looks OK, so it seems NetBeans is just doing something funny with the input. I don't have NetBeans to experiment with, but you might try wrapping System.in in a BufferedReader. Something like:

 
Nguyen Van Huong
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many people also surprise when I introduce my name. Wao, you have lived in Viet Nam( when you asked about my name, I guessed that you know Vietnamese ^^).

Well, I tried your code in my program and it worked well. Thanks for your enthusiasm!
 
Greg Charles
Sheriff
Posts: 3014
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm glad that worked. Yes, I lived in Viet Nam from 2003 to 2005 working for IBM, and again from 2007 to 2008 teaching English. I speak Vietnamese reasonably well, but have to keep studying it to keep it up.

I hope you'll stick around. We need more Vietnamese posters on this board!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!