Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Main;
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.List;
- import java.util.Scanner;
- public class ParseAndIterate {
- //Split the array
- static String splitBy = ",";
- //@init the Read
- static BufferedReader br = null;
- //@init the blank array
- public static String line = "";
- //Variables to save
- public static String symbol;
- public static String askPrice;
- public static String bidPrice;
- public static String realPrice;
- public static String volume;
- public static String dividendYield;
- static boolean downloadFile = GetFile.downloadFile;
- static String csvFile = GetFile.tempFile;
- static List<String> stockInfo = new ArrayList<String>();
- static String[] sqlString;
- static boolean parseDone = false;
- public static void IterateCSV() {
- if(downloadFile == true) {
- try {
- Scanner s = new Scanner(new File(csvFile));
- br = new BufferedReader(new FileReader(csvFile));
- while ((line = br.readLine()) != null) {
- sqlString = line.split(splitBy);
- int length = line.length();
- //System.out.println(line);
- stockInfo.add(line);
- }
- //Close the scanner and buffer
- br.close();
- s.close();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- symbol = stockInfo.get(0);
- String sql = Arrays.toString(sqlString);
- System.out.println("SQL String: " + sql);
- symbol = sqlString[0];
- askPrice = sqlString[1];
- bidPrice = sqlString[2];
- realPrice = sqlString[3];
- volume = sqlString[4];
- dividendYield = sqlString[5];
- parseDone = true;
- System.out.println("[Parse]: ParseDone: " + parseDone);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement