Java Reference
In-Depth Information
L ISTING 7.6 Continued
“Continue with Installation?”,
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.WARNING_MESSAGE);
if (choice == JOptionPane.OK_OPTION) {
copy();
} else {
printMessage(“User decided to abort installation.”);
printMessage(“To restart the installation visit again this page.”);
}
7
}
/**Stop the applet*/
public void stop() {
}
/**Destroy the applet*/
public void destroy() {
}
/**
* copies specified files on the specified local destination
*/
public void copy(){
String[] resources = getItems( getParameter(“resources”) );
String destDir = getParameter(“destination”);
if (resources==null || destDir==null) {
printMessage(“Invalid Parameter Settings.\n Installation aborted.”);
return;
}
BufferedInputStream in = null;
URL serverURL;
byte[] buffer;
try {
for (int i = 0; i < resources.length; i++) {
serverURL = new URL(getCodeBase(), resources[i]);
URLConnection conn = serverURL.openConnection();
in = new BufferedInputStream(conn.getInputStream());
String res = destDir+System.getProperty(“file.separator”)+resources[i];
new File(new File(res).getParent()).mkdirs();
FileOutputStream out = new FileOutputStream(res);
printMessage(“ - copying from:”+serverURL+” to:”+res);
buffer = new byte[2048];
Search WWH ::




Custom Search