Skip to content

Commit

Permalink
Fix: Updated FileParser to work in exported .jar
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyah committed May 14, 2026
1 parent 59f22d5 commit 8e72726
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void start(final Stage stage) throws Exception {
ViewManager viewManager = new ViewManager(stage, eventManager);

List<Stock> stocksInFile;
FileParser parser1 = new FileParser("src/main/resources/dummydata.txt");
FileParser parser1 = new FileParser("/dummydata.txt");

FileConverter converter1 = new FileConverter();
stocksInFile = converter1.getStocksFromStrings(parser1.readFile());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package edu.ntnu.idi.idatt2003.g40.mappe.service;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.*;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -120,8 +119,8 @@ public FileParser(final String pathName) {
* */

public List<String> readFile() throws IOException {
Path path = Paths.get(pathName);
try (BufferedReader bufferedReader = Files.newBufferedReader(path)) {
try (InputStream inputStream = getClass().getResourceAsStream(pathName);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) {

List<String> allLines = bufferedReader.readAllLines();
List<String> readableLines =
Expand Down

0 comments on commit 8e72726

Please sign in to comment.