mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-28 13:45:14 +01:00
Fixes bugs with copy file method.
This commit is contained in:
parent
e12eb85bce
commit
5a38c0b5e0
@ -25,8 +25,8 @@ public class FlatFileDatabaseConnector implements DatabaseConnector {
|
|||||||
|
|
||||||
private static final int MAX_LOOPS = 100;
|
private static final int MAX_LOOPS = 100;
|
||||||
private static final String DATABASE_FOLDER_NAME = "database";
|
private static final String DATABASE_FOLDER_NAME = "database";
|
||||||
private BentoBox plugin;
|
private final BentoBox plugin;
|
||||||
private File dataFolder;
|
private final File dataFolder;
|
||||||
|
|
||||||
|
|
||||||
public FlatFileDatabaseConnector(BentoBox plugin) {
|
public FlatFileDatabaseConnector(BentoBox plugin) {
|
||||||
@ -147,19 +147,12 @@ public class FlatFileDatabaseConnector implements DatabaseConnector {
|
|||||||
* @throws IOException - exception
|
* @throws IOException - exception
|
||||||
*/
|
*/
|
||||||
private void copyFileUsingStream(File source, File dest) throws IOException {
|
private void copyFileUsingStream(File source, File dest) throws IOException {
|
||||||
InputStream is = null;
|
try (InputStream is = new FileInputStream(source); OutputStream os = new FileOutputStream(dest)) {
|
||||||
OutputStream os = null;
|
|
||||||
try {
|
|
||||||
is = new FileInputStream(source);
|
|
||||||
os = new FileOutputStream(dest);
|
|
||||||
byte[] buffer = new byte[1024];
|
byte[] buffer = new byte[1024];
|
||||||
int length;
|
int length;
|
||||||
while ((length = is.read(buffer)) > 0) {
|
while ((length = is.read(buffer)) > 0) {
|
||||||
os.write(buffer, 0, length);
|
os.write(buffer, 0, length);
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
is.close();
|
|
||||||
os.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user