simplified logic

master
melvin 2011-08-03 15:27:54 +08:00
parent 8fb0381363
commit 62fec22d21
1 changed files with 17 additions and 18 deletions

View File

@ -1,26 +1,25 @@
package magic.data;
import java.io.*;
import java.util.Scanner;
import magic.MagicMain;
public class ReadMeFile {
private final String fileName;
public ReadMeFile(final String fileName){
this.fileName=fileName;
}
public String getDataFromFile() throws IOException{
StringBuilder text = new StringBuilder();
String NL = System.getProperty("line.separator");
Scanner scanner = new Scanner(new FileInputStream(fileName));
try{
while (scanner.hasNextLine()){
text.append(scanner.nextLine() + NL);
}
}
finally{
scanner.close();
}
return text.toString();
}
private final String fileName;
public ReadMeFile(final String fileName){
this.fileName=fileName;
}
public String getDataFromFile() throws IOException{
StringBuilder text = new StringBuilder();
String NL = System.getProperty("line.separator");
Scanner scanner = new Scanner(new FileInputStream(fileName));
while (scanner.hasNextLine()){
text.append(scanner.nextLine() + NL);
}
scanner.close();
return text.toString();
}
}