【发布时间】:2014-01-22 06:58:15
【问题描述】:
我正在读取一个包含位置和坐标列表的.txt 文件。
每一行都包含一个位置的名称、它的纬度和经度:
Downtown Flaggington 49.46419 -81.995353
Bender and Soonr 40.45519 -88.909353
...
如何将每行的最后 2 个数字去掉,只保留名称?
这就是我所拥有的:
public class GPSFileReverser
{
public static String reverse(Scanner in, String name, double lat, double lon) throws FileNotFoundException{
in = new Scanner(new File("gps-and-place.txt"));
GPSLocation[] gps = new GPSLocation[100];
for(int i = 0; i < 100; i++) {
name = in.nextLine();
name= name.;
lat = in.nextDouble();
lon = in.nextDouble();
GPSLocation currentGPS = new GPSLocation(name, lat, lon);
gps[i] = currentGPS;
}
return name + " " + lat + " \t " + lon;
}
}
【问题讨论】:
-
这是什么语言?