Hello,
I have a Java homework that I need to extract the data from ASCII Text file. Here is the ASCII text file http://weather.noaa.gov/data/nsd_bbsss.txt
72;211;KTPA;TAMPA INTERNATIONAL AIRPORT ;FL;United States;4;27-58N;082-32W;27-58-04N;082-31-33W;8;11;
72;212;KCTY;CROSS CITY AIRPORT;FL;United States;4;29-38N;083-06W;29-37-49N;083-06-31W;13;12;
72;213;KAYS;Waycross / Ware County, Ga;GA;United States;4;31-15N;082-24W;31-15N;082-24W;46;46;P
72;214;KTLH;TALLAHASSEE REGIONAL AIRPORT ;FL;United States;4;30-24N;84-21W;30-23-46N;084-21-20W;25;16;
72;215;----;Peachtree City, Ga.;GA;United States;4;33-22N;084-34W;33-22N;084-34W;262;244;
I need to extract only stations that locate in the UNited State only and unique station id. If the Station ID is ----, it will be skip
RIght now, I can get the Station ID but I need to get the Location, Latitude, and Longitude. Can everyone please help ?
Here is an example output
KTPA TAMPA INTERNATIONAL AIRPORT
Located in : FL
Latitude:27-58N
Longitude:082-32W
KCTY CROSS CITY AIRPORT
......
Here is my code that Im working so far
import java.util.Scanner;
import java.io.*;
import java.util.StringTokenizer;
public class a19006
{
public static void main (String[] args) throws IOException
{
String strPage;
String strData;
String strLine;
Scanner myInputFile;
int x;
String LinkURL = "http://weather.noaa.gov/data/nsd_bbsss.txt";
Inet net = new Inet();
strPage = net.getURLRaw(LinkURL);
PrintWriter myOutputFile = new PrintWriter("INFORMATION.TXT");
myOutputFile.println(strPage);
myOutputFile.close();
myInputFile = new Scanner(new File("INFORMATION.TXT"));
for (x=0; x<8500; x++)
{
myInputFile.nextLine();
}
PrintWriter OutputFile = new PrintWriter("OUTPUT.txt");
while (myInputFile.hasNext())
{
strLine = myInputFile.nextLine();
StringTokenizer strTokenizer = new StringTokenizer(strLine, ";");
while (strTokenizer.hasMoreTokens())
{
String str = strTokenizer.nextToken();
if (str.startsWith("K") && str.length() == 4)
{
OutputFile.println(str);
}
}
}
OutputFile.close();
myInputFile.close();
}
}