-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMyReader.java
More file actions
51 lines (34 loc) · 1023 Bytes
/
MyReader.java
File metadata and controls
51 lines (34 loc) · 1023 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import java.io.*;
import java.util.StringTokenizer;
public class MyReader{
BufferedReader br = null;
public MyReader(String company){
try{
br = new BufferedReader(new FileReader(company));
}catch(FileNotFoundException e){
System.out.println("File not found");
}
}
public int read(MyDate[] date, float[] open,float[] high, float[] low,
float[] close, double[] volume){
int count=0;
String line;
//Date = new String[250];
try{
line = br.readLine();
while ((line = br.readLine()) != null){
StringTokenizer st = new StringTokenizer(line," ");
date[count]=new MyDate(st.nextToken());
open[count]=Float.parseFloat(st.nextToken());
high[count]=Float.parseFloat(st.nextToken());
low[count] =Float.parseFloat(st.nextToken());
close[count]=Float.parseFloat(st.nextToken());
volume[count]=Double.parseDouble(st.nextToken());
count++;
}
}catch (IOException e){
System.out.println("Something else");
}
return count;
}
}