[英]Reading file and setting to variable
I'm new to programming, so I was wondering if someone could help me. 我是编程新手,所以我想知道是否有人可以帮助我。 What I'm trying to is make the user input a number, and if the number is in the file, it'll spit something back out, and if it's not in the file, it'll keep asking for a number.
我想做的是让用户输入一个数字,如果该数字在文件中,它将吐出一些东西,如果它不在文件中,它将不断询问一个数字。 I don't know exactly how to do this, but if someone could point me in the right direction, that would be great.
我不知道该怎么做,但是如果有人可以指出正确的方向,那就太好了。 Thanks in advance!
提前致谢!
Collection
, or as a big String
, the exact type depends on how you actually trying to achieve this). Collection
或Big String
,确切的类型取决于您实际尝试实现的方式)。 Scanner
, BufferedReader
or File.readAllLines()
Scanner
, BufferedReader
或File.readAllLines()
Bonus: 奖金:
Try to do each of the bullets in a different method and only combine them in your main()
- it will help you to learn about basic methods design as well. 尝试用不同的方法来处理每个项目符号,并且仅将它们组合在
main()
-这也将帮助您了解基本方法的设计。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.