Added bytereturn for file
This commit is contained in:
parent
8033c47f40
commit
611770fa1f
1 changed files with 12 additions and 9 deletions
9
src/zutil/io/file/FileUtil.java
Normal file → Executable file
9
src/zutil/io/file/FileUtil.java
Normal file → Executable file
|
|
@ -120,21 +120,22 @@ public class FileUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads and returns the content of a file as a String.
|
* Reads and returns the content of a file as a String.
|
||||||
* Or use FileUtils.readFileToString(file);
|
|
||||||
*
|
*
|
||||||
* @param file
|
* @param file
|
||||||
* @return the file content
|
* @return the file content
|
||||||
*/
|
*/
|
||||||
public static String getContent(File file) throws IOException{
|
public static String getContent(File file) throws IOException{
|
||||||
|
return new String(getByteContent(file));
|
||||||
|
}
|
||||||
|
public static byte[] getByteContent(File file) throws IOException {
|
||||||
InputStream in = new FileInputStream(file);
|
InputStream in = new FileInputStream(file);
|
||||||
String data = new String(IOUtil.getContent( in ));
|
byte[] data = IOUtil.getContent(in);
|
||||||
in.close();
|
in.close();
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads and returns the content of a file as a String.
|
* Reads and returns the content of a file as a String.
|
||||||
* Or use FileUtils.readFileToString(file);
|
|
||||||
*
|
*
|
||||||
* @param url
|
* @param url
|
||||||
* @return the file content
|
* @return the file content
|
||||||
|
|
@ -146,10 +147,12 @@ public class FileUtil {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache for the search functions
|
* Cache for the search functions
|
||||||
*/
|
*/
|
||||||
private static HashMap<SearchItem,List<File>> search_cache = new HashMap<SearchItem,List<File>>();
|
private static HashMap<SearchItem,List<File>> search_cache = new HashMap<SearchItem,List<File>>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An Cache Item class to identify different cached items
|
* An Cache Item class to identify different cached items
|
||||||
* @author Ziver
|
* @author Ziver
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue