Skip to content

Commit

Permalink
change the scanner with BufferedReader
Browse files Browse the repository at this point in the history
  • Loading branch information
johnprif committed May 9, 2023
1 parent 78fc6ce commit ef12369
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 16 deletions.
4 changes: 1 addition & 3 deletions bin/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/Control/
/Model/
/View/
/javafx-sdk-19/
/module-info.class
/Control/
Binary file modified bin/Control/PathHandler.class
Binary file not shown.
2 changes: 1 addition & 1 deletion databaseLocation.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
C:\Users\giann\Desktop\petalidi 10-10-22 demo\Databases\Logic Pro II - ���������.mdb
C:\Users\giann\Desktop\Logic Pro II - Αντιγραφή.mdb
44 changes: 32 additions & 12 deletions src/Control/PathHandler.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package Control;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.BufferedWriter;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Scanner;
import Model.DataBaseHandler;
Expand Down Expand Up @@ -112,19 +115,36 @@ public void checkPathFile()
}
}

private void readPath()
{
try {
Scanner myReader = new Scanner(myObj);
while (myReader.hasNextLine())
{
path = myReader.nextLine();
}
myReader.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
// private void readPath2()
// {
// try {
// Scanner myReader = new Scanner(myObj);
// while (myReader.hasNextLine())
// {
// path = myReader.nextLine();
// }
// myReader.close();
// } catch (FileNotFoundException e) {
// e.printStackTrace();
// }
// }

public void readPath()
{
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("databaseLocation.txt"), "UTF-8"))) {
String line;

while ((line = reader.readLine()) != null)
{
path = line;
System.out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
}

}


private void warningWindow()
{
Expand Down

0 comments on commit ef12369

Please sign in to comment.