-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created CSVFileHandler to reduce overhead code when reading stocks fr…
…om a CSV file Also changed where file information is passed to filereader and csvparser respectively to accommodate this change
- Loading branch information
Nikollai
committed
May 18, 2026
1 parent
932bee6
commit 2f63d03
Showing
7 changed files
with
51 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/millions/controller/fileIO/CSVFileHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package millions.controller.fileIO; | ||
|
|
||
| import millions.controller.fileIO.StockFileReader; | ||
| import millions.controller.fileIO.CSVStockFileParser; | ||
| import millions.model.Stock; | ||
|
|
||
| import java.nio.file.Path; | ||
| import java.util.List; | ||
|
|
||
| public class CSVFileHandler { | ||
| StockFileReader reader; | ||
| CSVStockFileParser parser; | ||
|
|
||
| public CSVFileHandler() { | ||
| this.reader = new StockFileReader(); | ||
| this.parser = new CSVStockFileParser(); | ||
| } | ||
|
|
||
| public List<Stock> getStocksFromFile(Path filePath) { | ||
| try { | ||
| StockFileReader reader = new StockFileReader(); | ||
| List<String> lines = reader.readFile(filePath); | ||
|
|
||
| CSVStockFileParser parser = new CSVStockFileParser(); | ||
| return parser.parse(lines); | ||
|
|
||
| } catch (InvalidFormatException e) { | ||
| throw new InvalidFormatException(e.getMessage()); | ||
| } | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters