Commit c20ca226 authored by Derek DeMoro's avatar Derek DeMoro Committed by derek

Moved over to WebManager copy methods.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1093 b35dd754-fafc-0310-a699-88a17e54d16e
parent 5e227297
...@@ -3,11 +3,12 @@ ...@@ -3,11 +3,12 @@
* $Revision$ * $Revision$
* $Date$ * $Date$
* *
* Copyright (C) 1999-2005 Jive Software. All rights reserved. * Copyright (C) 2004 Jive Software. All rights reserved.
* *
* This software is the proprietary information of Jive Software. Use is * This software is published under the terms of the GNU Public License (GPL),
subject to license terms. * a copy of which is included in this distribution.
*/ */
package org.jivesoftware.messenger.launcher; package org.jivesoftware.messenger.launcher;
import javax.swing.JFrame; import javax.swing.JFrame;
......
...@@ -16,6 +16,7 @@ import org.jdesktop.jdic.tray.SystemTray; ...@@ -16,6 +16,7 @@ import org.jdesktop.jdic.tray.SystemTray;
import org.jdesktop.jdic.tray.TrayIcon; import org.jdesktop.jdic.tray.TrayIcon;
import org.jivesoftware.messenger.JiveGlobals; import org.jivesoftware.messenger.JiveGlobals;
import org.jivesoftware.util.XMLProperties; import org.jivesoftware.util.XMLProperties;
import org.jivesoftware.util.WebManager;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JDialog; import javax.swing.JDialog;
...@@ -360,7 +361,7 @@ public class Launcher { ...@@ -360,7 +361,7 @@ public class Launcher {
// Copy Plugin into Dir. // Copy Plugin into Dir.
try { try {
URLFileSystem.copy(plugin.toURL(), tempPluginsFile); WebManager.copy(plugin.toURL(), tempPluginsFile);
// If successfull, rename to real plugin name. // If successfull, rename to real plugin name.
tempPluginsFile.renameTo(realPluginsFile); tempPluginsFile.renameTo(realPluginsFile);
......
...@@ -148,6 +148,7 @@ public abstract class SwingWorker { ...@@ -148,6 +148,7 @@ public abstract class SwingWorker {
t.start(); t.start();
} }
} }
} }
...@@ -25,6 +25,12 @@ import org.jivesoftware.messenger.group.GroupManager; ...@@ -25,6 +25,12 @@ import org.jivesoftware.messenger.group.GroupManager;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import java.net.URL;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.FileOutputStream;
/** /**
* A utility bean for Messenger admin console pages. * A utility bean for Messenger admin console pages.
...@@ -235,4 +241,48 @@ public class WebManager extends WebBean { ...@@ -235,4 +241,48 @@ public class WebManager extends WebBean {
ex.printStackTrace(); ex.printStackTrace();
} }
} }
/**
* Copies the contents at <CODE>src</CODE> to <CODE>dst</CODE>.
*/
public static void copy(URL src, File dst) throws IOException {
InputStream in = null;
OutputStream out = null;
try {
in = src.openStream();
out = new FileOutputStream(dst);
dst.mkdirs();
copy(in, out);
}
finally {
try {
if (in != null) in.close();
}
catch (IOException e) {
}
try {
if (out != null) out.close();
}
catch (IOException e) {
}
}
}
/**
* Common code for copy routines. By convention, the streams are
* closed in the same method in which they were opened. Thus,
* this method does not close the streams when the copying is done.
*/
private static void copy(InputStream in, OutputStream out)
throws IOException {
final byte[] buffer = new byte[4096];
while (true) {
final int bytesRead = in.read(buffer);
if (bytesRead < 0) {
break;
}
out.write(buffer, 0, bytesRead);
}
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment