Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Universities & Colleges (https://www.askmehelpdesk.com/forumdisplay.php?f=399)
-   -   Read from text file and store the values (https://www.askmehelpdesk.com/showthread.php?t=770006)

  • Oct 5, 2013, 02:29 AM
    mflevie44
    Read from text file and store the values
    My file has this kind of records on it

    34.53822859 69.47121593
    -6.235940397 14.21199344
    65.64550476 22.289417
    67.84077199 42.90517872
    24.72956344 63.9792445

    This is my code... I wan to know how can I add the above values in to array list. Or a normal array
    import java.io.*;
    public calss Test
    {
    public static void main(String [] args)
    {
    String file = "";
    //String strMin,strMax;
    double minTemp;
    double maxTemp;
    ArrayList<Double> list = new ArrayList<Double>();
    try
    {
    if(args[0].equals("Temp.txt"))
    {
    file = args[0];
    File myFlie = new File(file);
    FileReader flReader = new FileReader(myFile);

    BufferedReader br = new BufferedReader(flReader);

    String line = br.readLine();

    StringTokennizer st = new StingTokenizer(line,"\t");

    while(st.hasMoreTokens())
    {
    minTemp = Double.parseDouble(st.nextToken());
    maxTemp = Double.parseDouble(st.nextToken());

    list.add()
    }



    }
    }
    catch(Exception ex)
    {
    ex.printStackTrace();
    }
    }
    }

  • All times are GMT -7. The time now is 11:20 PM.