Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Parser{
- private final HashMap val <String, String>;
- private final File source;
- public Parser(final File path){
- /*initialise stuff*/
- val=new HashMap<>();
- source=path; //throws exception if null but omitted for brevity
- /* and finally parse the file */
- parse();
- }
- public void parse() {
- final Scanner sc=new Scanner(source);
- while(sc.hasNextLine()){
- //do stuff
- }
- sc.close();
- }
- private void parseDecision(final String possibleStr){
- final Scanner sc;
- if(possibleStr==null) //use File
- sc=new Scanner(source); //remember source is a field
- else
- sc=new Scanner(possibleStr);
- /*...*/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement