i want to get text from console screen

for example

System.out.println("hello");

i want to get that "hello" and store it in string how to do that?????

Recommended Answers

All 2 Replies

You can use System.setOut(PrintStream out) to redirect all System.out.print data to the stream of your choice. If you use a ByteArrayOutputStream then you will get all the output in a byte array that can easily be converted to a String.
Is that what you meant?

commented: Yep; that's the way I usually do it. +6

actually, when you write System.out.println("hello");
you already have it in a String. are you trying to work with input through the command prompt?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.