Hey I'm pretty lost, hence my username, but I have this code here:
package downloadtesting; import java.io.*; import java.net.*; import javax.swing.JFileChooser; public class FileDownLoader { private JFileChooser jfc; public boolean saveUrl(String urlString) throws MalformedURLException, IOException { BufferedInputStream in = null; FileOutputStream fout = null; jfc = new JFileChooser(); if(jfc.showSaveDialog(null) == JFileChooser.APPROVE_OPTION){ try { File selectedFile = jfc.getSelectedFile(); in = new BufferedInputStream(new URL(urlString).openStream()); fout = new FileOutputStream(selectedFile); byte data[] = new byte[1024]; int count; while ((count = in.read(data, 0, 1024)) != -1) { fout.write(data, 0, count); } } finally { if (in != null) in.close(); if (fout != null) fout.close(); } return true; } else { return false; } } }
Which I'm trying to use to download a .jar file from my shell account for testing, however nothing is even being saved.
So what I'm trying to do is have this class/method download a jar file from my webhost and save it to where I specify with JFileChooser.showSaveDilog, however nothings even being saved, stuck and help much appreciated.