Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ```package gui;
- import java.io.BufferedReader;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.IOException;
- /**
- * @author DylanPW
- *
- * Class for parsing CSVs loaded into the application.
- */
- public class CSVParse {
- String csvPath;
- /**
- * Constructor for parsing CSVs of the specified path.
- * @param csvPath
- */
- public CSVParse(String csvPath){
- this.csvPath = csvPath;
- }
- /**
- * Class for parsing item lists.
- */
- public void parseItems() {
- BufferedReader br = null;
- // new store
- String line = "";
- String csvDelimiter = ",";
- try {
- br = new BufferedReader(new FileReader(csvPath));
- String[] item = line.split(csvDelimiter);
- // [item],[cost],[price],[reorder point],[reorder amount],[temperature]
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } finally {
- if (br != null) {
- try {
- br.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- }
- /**
- * Class for parsing sales logs
- */
- public void parseSalesLog() {
- BufferedReader br = null;
- String line = "";
- String csvDelimiter = ",";
- try {
- br = new BufferedReader(new FileReader(csvPath));
- String[] item = line.split(csvDelimiter);
- // [item],[quantity]
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } finally {
- if (br != null) {
- try {
- br.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- }
- /**
- * Class for parsing manifests
- */
- public void parseManifest() {
- BufferedReader br = null;
- String line = "";
- String newTruck = ">";
- String csvDelimiter = ",";
- try {
- br = new BufferedReader(new FileReader(csvPath));
- if(line.startsWith(newTruck)) {
- String[] item = line.split(newTruck);
- String truckType = item[1];
- // type of truck
- } else {
- String[] item = line.split(csvDelimiter);
- // [item],[quantity]
- }
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } finally {
- if (br != null) {
- try {
- br.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- }
- }
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement