Advertisement
riking

Untitled

Aug 16th, 2013
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. public void downloadUpdatedPlugin(String pluginName, String dboFileUrl) {
  2.     String location = "http://dev.bukkit.org/media/files/" + dboFileUrl;
  3.     File output = new File(Bukkit.getUpdateFolder(), pluginName + ".jar");
  4.     try {
  5.         URL url = new URL(location);
  6.         BufferedInputStream in = new BufferedInputStream(url.openStream());
  7.         BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(output));
  8.         byte[] buf = new byte[4096];
  9.         int tmp;
  10.         while ((tmp = in.read(buf)) != -1) {
  11.             out.write(buf, 0, tmp);
  12.         }
  13.         in.close();
  14.         out.flush();
  15.         out.close();
  16.     //} catch (MalformedURLException e) {
  17.     //} catch (IOException e) {
  18.     } catch (Exception e) {
  19.         e.printStackTrace();
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement