Added File copy method
This commit is contained in:
parent
25d70c8075
commit
d3f3c02f78
4 changed files with 330 additions and 313 deletions
0
Zutil.jar
Normal file → Executable file
0
Zutil.jar
Normal file → Executable file
0
src/zutil/db/DBConnection.java
Normal file → Executable file
0
src/zutil/db/DBConnection.java
Normal file → Executable file
5
src/zutil/io/IOUtil.java
Normal file → Executable file
5
src/zutil/io/IOUtil.java
Normal file → Executable file
|
|
@ -55,7 +55,7 @@ public class IOUtil {
|
|||
|
||||
/**
|
||||
* Reads and returns all the content of a stream as a String.
|
||||
* This function will close the inout stream at the end.
|
||||
* This function will close the input stream at the end.
|
||||
*
|
||||
* @param stream
|
||||
* @return a String with the content of the stream
|
||||
|
|
@ -73,7 +73,8 @@ public class IOUtil {
|
|||
}
|
||||
|
||||
/**
|
||||
* Copies all data from the input stream to the output stream
|
||||
* Copies all data from the input stream to the output stream.
|
||||
* The input stream will not be closed after method has returned.
|
||||
*/
|
||||
public static void copyStream(InputStream in, OutputStream out) throws IOException {
|
||||
byte[] buff = new byte[256];
|
||||
|
|
|
|||
|
|
@ -87,6 +87,21 @@ public class FileUtil {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy the contents of a source file to another file.
|
||||
* NOTE: the method will replace the destination file if it exists.
|
||||
*
|
||||
* @param source
|
||||
* @param destination
|
||||
*/
|
||||
public static void copy(String source, String destination) throws IOException{
|
||||
try (BufferedInputStream in = new BufferedInputStream(new FileInputStream(source));
|
||||
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(destination));){
|
||||
|
||||
IOUtil.copyStream(in, out);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the URL to the given file
|
||||
*
|
||||
|
|
@ -164,6 +179,7 @@ public class FileUtil {
|
|||
*/
|
||||
private static HashMap<SearchItem,List<File>> search_cache = new HashMap<SearchItem,List<File>>();
|
||||
|
||||
|
||||
/**
|
||||
* An Cache Item class to identify different cached items
|
||||
* @author Ziver
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue