Skip to content

Commit

Permalink
Create Printer.java
Browse files Browse the repository at this point in the history
  • Loading branch information
giusepped committed Aug 22, 2014
1 parent 695d7b0 commit a1df9cf
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Week9/Printer/Printer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

/**
*
* @author giuseppedesantis
*/

import java.util.Scanner;
import java.io.File;

public class Printer {
private File textFile;
private Scanner reader;

public Printer(String fileName) throws Exception{
this.textFile = new File(fileName);
this.reader = new Scanner(this.textFile, "UTF-8");
}

public void printLinesWhichContain(String word){
if(word == ""){
System.out.println(this.textFile);
}else{
while(reader.hasNextLine()){
String line = reader.nextLine();
if(line.contains(word)){
System.out.println();
}
}
}
}

}

0 comments on commit a1df9cf

Please sign in to comment.