Why won't ">> " print at the end of my printf statement?

uwjklwme23584729

I am trying to use the Jansi Java Library for using color in the CMD/Console and I have come across a little problem. When I use the Jansi Library and try to use the print f statement

System.out.printf("Hello young lad! What is thy " + RED + "name " + WHITE + "you were given at birth?\n>> ");

the ">> " doesn't print at the end. Instead, the Scanner is called and asks for my input. Why does this happen and is there any way i can make it so that the ">> " and the Scanner input appear on one line?

import java.util.Scanner;

import org.fusesource.jansi.AnsiConsole;


public class Test {
    public static void main(String[] args) {
        AnsiConsole.systemInstall();

        String name;
        Scanner scanner = new Scanner(System.in);

        String BLACK = "\u001B[0;30m";
        String RED = "\u001B[0;31m";
        String GREEN = "\u001B[0;32m";
        String YELLOW = "\u001B[0;33m";
        String BLUE = "\u001B[0;34m";
        String MAGENTA = "\u001B[0;35m";
        String CYAN = "\u001B[0;36m";
        String WHITE = "\u001B[0;37m";

        System.out.printf("Hello young lad! What is thy " + RED + "name " + WHITE + "you were given at birth?\n>> ");
        name = scanner.nextLine();
    }
}
peter.petrov

This code works fine after commenting out the AnsiConsole thing.

This is what I get printed out.

Hello young lad! What is thy [0;31mname [0;37myou were given at birth?
>> John

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Why won't my HTML page print according to my CSS document?

来自分类Dev

Why won't my simple angularjs work?

来自分类Dev

Why won't my init.d service start?

来自分类Dev

Why won't Android Studio create my AAR file in release mode

来自分类Dev

Why does the printf statement in this loop output the array out of sequence?

来自分类Dev

Why won't Ubuntu Terminal accept "\" character?

来自分类Dev

Awk printf()覆盖print()

来自分类Dev

SQLite3 - Why won't the referential data delete?

来自分类Dev

Why does my sort print out multiple lists?

来自分类Dev

print(...,end ='')立即输出

来自分类Dev

Why my SeekBar isn't updating?

来自分类Dev

Why doesn't the HashMap print after loading ArrayList values into it?

来自分类Dev

怎么把printf转换成print?

来自分类Dev

how to print the size of a matrix in a print statement?

来自分类Dev

A WHERE statement in my SqlDataSource causes invalid character exception (ORA-00911), why?

来自分类Dev

why doesn't my c# base constructor get called?

来自分类Dev

Why don't my points display in Haskell OpenGL?

来自分类Dev

Why isn't read_csv() parsing my dates?

来自分类Dev

Why isn't my class constructor initializing its member variables?

来自分类Dev

Why doesn't Perl see my file in the working Windows directory?

来自分类Dev

在方法'my_print_hexbytes'中,类型'uint32_t *'的参数1

来自分类Dev

QFuture<void> won't work

来自分类Dev

Perl中的printf,print和sprintf之间的区别?

来自分类Dev

How does printf() 'mysteriously' know what I intended to print?

来自分类Dev

首选的System.out.print()或System.out.printf()?

来自分类Dev

为什么在此命令中同时存在printf和print?

来自分类Dev

删除 awk printf / print 之间的空格分隔符

来自分类Dev

Why the second statement does not work?

来自分类Dev

C++ file won't open

Related 相关文章

  1. 1

    Why won't my HTML page print according to my CSS document?

  2. 2

    Why won't my simple angularjs work?

  3. 3

    Why won't my init.d service start?

  4. 4

    Why won't Android Studio create my AAR file in release mode

  5. 5

    Why does the printf statement in this loop output the array out of sequence?

  6. 6

    Why won't Ubuntu Terminal accept "\" character?

  7. 7

    Awk printf()覆盖print()

  8. 8

    SQLite3 - Why won't the referential data delete?

  9. 9

    Why does my sort print out multiple lists?

  10. 10

    print(...,end ='')立即输出

  11. 11

    Why my SeekBar isn't updating?

  12. 12

    Why doesn't the HashMap print after loading ArrayList values into it?

  13. 13

    怎么把printf转换成print?

  14. 14

    how to print the size of a matrix in a print statement?

  15. 15

    A WHERE statement in my SqlDataSource causes invalid character exception (ORA-00911), why?

  16. 16

    why doesn't my c# base constructor get called?

  17. 17

    Why don't my points display in Haskell OpenGL?

  18. 18

    Why isn't read_csv() parsing my dates?

  19. 19

    Why isn't my class constructor initializing its member variables?

  20. 20

    Why doesn't Perl see my file in the working Windows directory?

  21. 21

    在方法'my_print_hexbytes'中,类型'uint32_t *'的参数1

  22. 22

    QFuture<void> won't work

  23. 23

    Perl中的printf,print和sprintf之间的区别?

  24. 24

    How does printf() 'mysteriously' know what I intended to print?

  25. 25

    首选的System.out.print()或System.out.printf()?

  26. 26

    为什么在此命令中同时存在printf和print?

  27. 27

    删除 awk printf / print 之间的空格分隔符

  28. 28

    Why the second statement does not work?

  29. 29

    C++ file won't open

热门标签

归档