Added screen-capture functionality (press D). Added safeguards to prevent NPE when player.txt, DetailedInfo.txt do not exist. Removed these files from source control.
This commit is contained in:
@@ -5,33 +5,27 @@ import java.io.FileReader;
|
||||
|
||||
public class FileHandler {
|
||||
|
||||
public static String readFile(String fileName){
|
||||
public static String readFile(String fileName) {
|
||||
String info = "";
|
||||
try {
|
||||
FileReader input = new FileReader(fileName);
|
||||
BufferedReader bufRead = new BufferedReader(input);
|
||||
|
||||
String line;
|
||||
|
||||
int count = 0;
|
||||
line = bufRead.readLine();
|
||||
info = line +"\n";
|
||||
count++;
|
||||
|
||||
|
||||
while (line != null){
|
||||
// System.out.println(count+": "+line);
|
||||
line = bufRead.readLine();
|
||||
info += line + "\n";
|
||||
count++;
|
||||
}
|
||||
|
||||
bufRead.close();
|
||||
|
||||
}catch (Exception e){
|
||||
// If another exception is generated, print a stack trace
|
||||
e.printStackTrace();
|
||||
}
|
||||
return info;
|
||||
|
||||
String line;
|
||||
|
||||
line = bufRead.readLine();
|
||||
info = line + "\n";
|
||||
|
||||
while (line != null) {
|
||||
line = bufRead.readLine();
|
||||
info += line + "\n";
|
||||
}
|
||||
|
||||
bufRead.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
System.out.println("Unable to read from file: " + fileName +", returning empty String.");
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user