This commit is contained in:
Ziver Koc 2009-01-13 00:48:46 +00:00
parent d699626cf0
commit 9e3de28d45
3 changed files with 216 additions and 0 deletions

View file

@ -1,6 +1,9 @@
package zutil;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
@ -52,6 +55,28 @@ public class FileFinder {
return null;
}
/**
* Reads and returns the content of a file as a String.
* Or use FileUtils.readFileToString(file);
*
* @param file The file to read
* @return The file content
* @throws IOException
*/
public static String getFileContent(File file) throws IOException{
BufferedReader in = new BufferedReader(new FileReader(file));
StringBuffer ret = new StringBuffer();
int tmp;
while((tmp=in.read()) != -1){
ret.append((char)tmp);
}
in.close();
return ret.toString();
}
/**
* Returns the URL to the given file
*