Java向文本文件添加控制台输入

发布于 2025-02-08 23:56:02 字数 291 浏览 1 评论 0原文

我有一个关于爪哇io*的问题。

我如何将内容输入到Java控制台中,后者将其添加到链接到的Java文件后。

问题是我需要创建一个人数据库,为此我可以通过电子邮件,号码等创建一个新的人(当然,只有当我可以使用此信息时,我才能创建该人的个人资料。 我知道如何将文本文件链接到我的Java文件并在控制台中显示其内容,但是为了做到这一点,我只知道如何将输出添加到Java源代码中。但是我需要能够在控制台中创建新的人条目。

简单说:我是银行经理,只有控制台可以创建一个新的人数据库,但我无法访问源代码。我希望这里的问题很清楚。提前致谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

温暖的光 2025-02-15 23:56:02

不是100%确定的,但我假设:

  1. 您想将控制台用作Java应用程序的输入,
  2. 然后使用此输入来创建人对象
  3. ,然后将其保存到数据库或文本文件中。

这是Java中常见的用例,请检查此示例。
例如,您有很多选择可以实现这一目标

        // Using System Console to read inputs from users
        String line = System.console().readLine();
 
        System.out.println("Entered string " + line);

:从输入创建对象。

您也可以在循环时或循环创建,直到给定命令不好为止。

希望我能理解您的问题。

Not 100% sure, but I assume:

  1. you would like to use the console as an input for your Java application,
  2. and then using this input to create Person objects
  3. and then save it into a database or to a text file.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文