-
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.
Merge pull request #48 from IDATT2003-gruppe06/file-io-development
File io development
- Loading branch information
Showing
8 changed files
with
67 additions
and
45 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/CSV/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.CSV; | ||
|
|
||
| import millions.controller.fileIO.InvalidFormatException; | ||
| import millions.controller.fileIO.StockFileReader; | ||
| 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
3 changes: 2 additions & 1 deletion
3
...controller/fileIO/CSVStockFileWriter.java → ...roller/fileIO/CSV/CSVStockFileWriter.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
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