Life has to be something better than what we can see around us. It must be a kind of utopia that’s just beyond that hill, or just a little bit after the horizon. Whatever the case, it has to be there. I don’t see any other way on how this would work. I think it’s up to us to make life better than it is. Does that make sense? I sure hope it does to someone who’s reading this. If it does then I’ve done something right. If it doesn’t? Well that’s another story for another time.
Ah the fun times of inputting data from the command line in a Java program.
Java has come a long way in this respect. From starting with IO Streams to what they have now. Currently, there is a Console class in the java.io package. Here's a simple test I did capturing data the user enters:
import java.io.Console;
import java.io.IOException;
public class Test {
public Test() {
}
public static void main(String[] args) throws IOException {
String in = null;
Console c = System.console();
if (c == null) {
System.err.println("No console.");
System.exit(1);
}
while (!(in = c.readLine("> ")).equals(".quit")) {
// do something with the content you just captured
System.out.println(in);
}
}
}
That's a very simple program now isn't it? Just accepts whatever you enter and echos it back out to the screen. If you type in .quit it will quit the program.
So yep, just a simple program for capturing data in a Console application.
Comments
Post a Comment