Java:带文件读取器的程序
尽管我尽了最大的努力,我还是不知道如何解决这个问题。我为它的奶酪味道歉,我是一名学习java的学生,并被作为一种练习Java:带文件读取器的程序,java,file-io,filereader,Java,File Io,Filereader,尽管我尽了最大的努力,我还是不知道如何解决这个问题。我为它的奶酪味道歉,我是一名学习java的学生,并被作为一种练习 Lixnor is a mutant space trader in the Andromeda IV galaxy. He is low on supplies and funds and has trouble paying for the fuel that his ship requires. Every SGW (Standard Galactic Week) hi
Lixnor is a mutant space trader in the Andromeda IV galaxy. He is low on
supplies and funds and has trouble paying for the fuel that his ship
requires. Every SGW (Standard Galactic Week) his partner, Ronxil gives him
the coordinates for 2 valuable lost crates floating in space. The
coordinates are sent in a file named "Coordinates.txt". The files always
have 3 lines, each line containing a coordinate in the format (x,y,z) where
x,y,z are integers. Due to Lixnor's lack of funds, he must first calculate
whether it would be worth it for him to go pick them up. The first
coordinates given are Lixnor's current coordinates, and the next two are the
coordinates of the two crates. Lixnor must pick them up, then return to his
original location. Write a program for Lixnor that calculates the distance
he must travel in order to pick up the crates and return to his original
position.
(24,-34,46)
(1,2,3)
(123,-1,0)
具体地说,我很难让Java读取该文件。任何帮助都会很棒 查看的javadoc
Path-Path=Path.get(“……txt”);
列表行=文件。readAllLines(路径);//使用UTF-8
这是一种可能性。处理过程由您决定。读取文件很简单
- 使用
file file=new file(字符串fileAddress)获取文件实例代码>
- 现在使用
读取文件Scanner Scanner=新扫描仪(文件)
因此,如果没有代码,我们将无能为力。学习Java文件读取器。试着去做,然后带着一些代码回来。那我们就可以帮忙了。
Path path = Paths.get(".... .txt");
List<String> lines = Files.readAllLines(path); // Using UTF-8