Reputation: 1
I have a question regarding java io*.
How can I input things into the java console, which after inputting gets added to the java file linked to.
The problem is that I need to create a people database, for which I can create a new Person, with email, number etc (of course only if this information is available to me, so that I can create that person's profile. I know how to link a text file to my java file and also display the content of it in the console, but in order to do that I only know how to add that output to the java source code. But I need to be able to create new persons entries in the console.
Easy said: I am a bank manager and only have the console to create a new people database but I do not have access to the source code. I hope the problem here is clear. Thanks in advance.
Upvotes: 0
Views: 393
Reputation: 4919
Not 100% sure, but I assume:
It is a common use case in Java, please check this example. You have many options basically to achieve this, for example:
// Using System Console to read inputs from users
String line = System.console().readLine();
System.out.println("Entered string " + line);
If you manage to understand this, and so read a line from input, then you can check this name, or command, you can create if/else, and other instructions and you can create objects from the inputs.
You can also create while or for loops until the given command is not good.
I hope I understand good your question.
Upvotes: 1