Java BufferedReader Read loadWaypoints(File inFile)

Here you can find the source of loadWaypoints(File inFile)

Description

Given a text file, this method loads a list of waypoints into a vector structure

License

Open Source License

Parameter

Parameter Description
inFile The file where to read the waypoints from

Exception

Parameter Description
Exception If there is an error reading the file or an error with the file format

Return

The list of loaded waypoints (lat, lon, depth)

Declaration

public static Vector<double[]> loadWaypoints(File inFile) throws Exception 

Method Source Code


//package com.java2s;
/*//from w ww .jav a2s . c  o m
 * Copyright (c) 2004-2013 Universidade do Porto - Faculdade de Engenharia
 * Laborat?rio de Sistemas e Tecnologia Subaqu?tica (LSTS)
 * All rights reserved.
 * Rua Dr. Roberto Frias s/n, sala I203, 4200-465 Porto, Portugal
 *
 * This file is part of Neptus, Command and Control Framework.
 *
 * Commercial Licence Usage
 * Licencees holding valid commercial Neptus licences may use this file
 * in accordance with the commercial licence agreement provided with the
 * Software or, alternatively, in accordance with the terms contained in a
 * written agreement between you and Universidade do Porto. For licensing
 * terms, conditions, and further information contact lsts@fe.up.pt.
 *
 * European Union Public Licence - EUPL v.1.1 Usage
 * Alternatively, this file may be used under the terms of the EUPL,
 * Version 1.1 only (the "Licence"), appearing in the file LICENCE.md
 * included in the packaging of this file. You may not use this work
 * except in compliance with the Licence. Unless required by applicable
 * law or agreed to in writing, software distributed under the Licence is
 * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF
 * ANY KIND, either express or implied. See the Licence for the specific
 * language governing permissions and limitations at
 * https://www.lsts.pt/neptus/licence.
 *
 * For more information please see <http://lsts.fe.up.pt/neptus>.
 *
 * Author: Jos? Pinto
 * Oct 16, 2012
 */

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.Vector;

public class Main {
    /**
     * Given a text file, this method loads a list of waypoints into a vector structure
     * @param inFile The file where to read the waypoints from
     * @return The list of loaded waypoints (lat, lon, depth)
     * @throws Exception If there is an error reading the file or an error with the file format
     */
    public static Vector<double[]> loadWaypoints(File inFile) throws Exception {
        BufferedReader reader = new BufferedReader(new FileReader(inFile));

        String line = reader.readLine();
        Vector<double[]> locs = new Vector<double[]>();
        while (line != null) {
            line = line.trim();
            line = line.replaceAll("\\s+", "\t");
            String[] parts = line.trim().split("\\t");
            double[] loc = new double[3];
            loc[0] = Double.parseDouble(parts[0]);
            loc[1] = Double.parseDouble(parts[1]);
            loc[2] = Double.parseDouble(parts[2]);
            locs.add(loc);
            line = reader.readLine();
        }

        reader.close();
        return locs;
    }
}

Related

  1. loadTwoColumnResource(InputStream resource)
  2. loadTxnDescriptions(String filename)
  3. loadTXTList(String listFile, int size)
  4. loadUnicodeStringFromFile(final File file)
  5. loadVocab(String vocabFilePath, double factor)
  6. loadXML(String fileName)
  7. loadXMLDocumentFromClasspath(String resourcePath)
  8. loadY(InputStream filePath)
  9. readFile(File f)