0
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class readandstore {
        private static List<String> timesArray = new ArrayList<String>();

        public static void main(String[] args) 
        {
            try {
                File file = new File("src/Location.txt");
                Scanner scanner = new Scanner(file);
                while (scanner.hasNextLine()) {
                    String[] times = scanner.nextLine().split("____");

                    System.out.println(times[0]);
                    System.out.println("Latitude: " + times[1]);
                    System.out.println("Longitude: " + times[2]);

                    System.out.println();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
}

我现在列出所有位置及其坐标(纬度、经度)。

但现在我必须显示给定的两个连接位置之间的距离。

我怎样才能做到这一点?

附录:

位置.txt

Borneo Convention Center Kuching____1.562697____110.405642 
Boulevard Shopping Mall____1.509437____110.335928 
CityOne____1.520591____110.354800 
Crown Square____1.550943____110.369058 
EMart, Matang____1.571942____110.302713 
Giant, Padawan____1.429855____110.326926 
Giant, Tabuan Laru____1.515947____110.386375 
Green Height Mall____1.502219____110.346270 
Hills Shopping Mall____1.555447____110.351097 
Kuching International Airport____1.486785____110.342170 
Kuching Sentral____1.481680____110.332257 
Merdeka Plaza____1.558450____110.344232 
OneJaya____1.517969____110.365889 
OneTJ____1.506375____110.374686 
Saberkas____1.537204____110.340219 
Sarawak Plaza____1.557517____110.353963 
Spring Shopping Mall____1.535434____110.357598 
Summer Mall____1.453773____110.441562 
Tabuan Plaza____1.532373____110.375899 
Wisma Hopoh____1.554203____110.340477 
Wisma Satok____1.553667____110.335132 

连接.txt

Borneo Convention Center Kuching____Crown Square 
Boulevard Shopping Mall____Green Height Mall 
Boulevard Shopping Mall____Kuching Sentral 
Boulevard Shopping Mall____Saberkas 
CityOne____Green Height Mall 
CityOne____OneJaya 
CityOne____Saberkas 
CityOne____Spring Shopping Mall 
Crown Square____Borneo Convention Center Kuching 
Crown Square____Hills Shopping Mall 
Crown Square____Sarawak Plaza 
Crown Square____Spring Shopping Mall 
Crown Square____Tabuan Plaza 
EMart, Matang____Wisma Satok 
Giant, Padawan____Kuching Sentral 
Giant, Tabuan Laru____OneJaya 
Giant, Tabuan Laru____OneTJ 
Giant, Tabuan Laru____Summer Mall 
Giant, Tabuan Laru____Tabuan Plaza 
Green Height Mall____Boulevard Shopping Mall 
Green Height Mall____CityOne 
Green Height Mall____Kuching International Airport 
4

0 回答 0