Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Scanner not working well when i Run my java program as batch

  1. #1
    Junior Member
    Join Date
    Apr 2021
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Scanner not working well when i Run my java program as batch

    Hello,

    Scanner not working well when i Run my java program as batch.
    How can I remove from the String the new line (\n)?

    For example:
    String example = "Hello World!\n";

    I want to remove the new line tag.

    I think I can remove it only Ascii code (Because not contains \n), but i can't use it.

    Is there any other way to specify the value of the usedelimiter?

    I'm using this:
    Scanner be = new Scanner(System.in).useDelimiter("\n");

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Scanner not working well when i Run my java program as batch

    I want to remove the new line tag.
    Sorry, I don't understand what you are trying to do.
    Can you explain what you want the user to see when he uses your program in a command prompt? How do you want the program to interact with what the user enters at the keyboard.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. [SOLVED] Scanner not working
    By Arno in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 14th, 2020, 11:30 AM
  2. batch printing of files in java
    By ksaravanan in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 21st, 2014, 08:07 AM
  3. how can i create batch file using java ...
    By santosh tiwary in forum What's Wrong With My Code?
    Replies: 6
    Last Post: December 9th, 2013, 10:14 AM
  4. Scanner not working?
    By ryno893 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: July 13th, 2012, 08:07 AM
  5. Scanner not working properly.
    By kookevk in forum What's Wrong With My Code?
    Replies: 9
    Last Post: January 25th, 2012, 10:14 PM

Tags for this Thread