Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. public class Parser{
  2. private final HashMap val <String, String>;
  3. private final File source;
  4.  
  5. public Parser(final File path){
  6. /*initialise stuff*/
  7. val=new HashMap<>();
  8. source=path; //throws exception if null but omitted for brevity
  9. /* and finally parse the file */
  10. parse();
  11. }
  12.  
  13. public void parse() {
  14. final Scanner sc=new Scanner(source);
  15. while(sc.hasNextLine()){
  16. //do stuff
  17. }
  18. sc.close();
  19. }
  20.  
  21. private void parseDecision(final String possibleStr){
  22. final Scanner sc;
  23.  
  24. if(possibleStr==null) //use File
  25. sc=new Scanner(source); //remember source is a field
  26. else
  27. sc=new Scanner(possibleStr);
  28. /*...*/
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement