Skip to content
Snippets Groups Projects
Commit 8e39fbf6 authored by ddnguyen's avatar ddnguyen
Browse files

add tools - FileScanner

parent 7ae0760a
No related branches found
No related tags found
No related merge requests found
No preview for this file type
package tools; package tools;
import java.io.*;
import java.util.Scanner;
public class FileScanner { public class FileScanner {
private final File file;
private Scanner scanner;
public static String commentCharacter = "//";
public FileScanner(final String filePath) {
this.file = new File(filePath);
try {
this.scanner = new Scanner(file);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
public boolean hasNextLine() {
return scanner.hasNext();
}
public String readLine() {
String line = scanner.nextLine();
// Check if the line does not start with the comment character
while(line.startsWith(commentCharacter) || line.isEmpty()) {
line = scanner.nextLine();
}
return line;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment