Java BufferedReader Read loadY(InputStream filePath)

Here you can find the source of loadY(InputStream filePath)

Description

load Y

License

Apache License

Declaration

public static double[] loadY(InputStream filePath) throws IOException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static double[] loadY(InputStream filePath) throws IOException {

        String line;//from  ww w .  j a  v a2  s . c  om
        double[] data;
        List<Double> list = new ArrayList<Double>();

        BufferedReader reader = null;
        try {
            reader = new BufferedReader(new InputStreamReader(filePath));
            while ((line = reader.readLine()) != null) {
                list.add(Double.parseDouble(line.trim()));
            }
        } finally {
            if (reader != null)
                reader.close();
        }

        data = new double[list.size()];
        for (int i = 0; i < list.size(); i++)
            data[i] = list.get(i);

        return data;
    }

    public static double[] loadY(String filePath) throws IOException {

        return loadY(new FileInputStream(filePath));
    }
}

Related

  1. loadUnicodeStringFromFile(final File file)
  2. loadVocab(String vocabFilePath, double factor)
  3. loadWaypoints(File inFile)
  4. loadXML(String fileName)
  5. loadXMLDocumentFromClasspath(String resourcePath)
  6. readFile(File f)
  7. readFile(File f)
  8. readFile(File f)
  9. readFile(File f)