package org.neuroph.contrib.samples.stockmarket;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.net.URL;


public class TextReader {
	
	public double[] pastvals=new double[89]; //And array of doubles

	public TextReader(){
		Read();
		
	}
	
	public void Read(){
		 try{
			 URL url = getClass().getResource("microsoft.txt"); //Currently hard coded textfile
			 String path= url.toString();
			 path=path.substring(5);
                         //System.out.println(path);
			  FileInputStream fstream = new FileInputStream(path);
			  
			  DataInputStream in = new DataInputStream(fstream);
			  BufferedReader br = new BufferedReader(new InputStreamReader(in));
			  String strLine;
			  int counter=0;
			  while ((strLine = br.readLine()) != null)   {
			  
			  pastvals[counter]=Double.parseDouble(strLine); //Takes the value on the specific line and puts it into an array
			//  System.out.println (pastvals[counter]);

			  counter++;  //increase counter by one
			  }
		
			  in.close();
			    }catch (Exception e){//Catch exception if any
			  System.err.println("Error: " + e.getMessage()); //For any exception 
			  }
	}
	

}

