forked from LogBlock/LogBlock
Added auto downloader for the mysql connector
Moved mysql connector to lib/
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package de.diddiz.util;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URL;
|
||||
|
||||
public class Download
|
||||
{
|
||||
public static void download(URL u, File file) throws Exception {
|
||||
if (!file.getParentFile().exists())
|
||||
file.getParentFile().mkdir();
|
||||
if (file.exists())
|
||||
file.delete();
|
||||
file.createNewFile();
|
||||
InputStream in = u.openStream();
|
||||
OutputStream out = new BufferedOutputStream(new FileOutputStream(file));
|
||||
byte[] buffer = new byte[1024];
|
||||
int len;
|
||||
while ((len = in.read(buffer)) >= 0) {
|
||||
out.write(buffer, 0, len);
|
||||
}
|
||||
in.close();
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user