Initial commit.
This commit is contained in:
37
src/dk/itu/mario/engine/util/FileHandler.java
Normal file
37
src/dk/itu/mario/engine/util/FileHandler.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package dk.itu.mario.engine.util;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
|
||||
public class FileHandler {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user