witam mam taki problem , mianowicie chce wywalac przerwanie sciagania plikow .
String url = "http://sourceforge.net/projects/filezilla/files/FileZilla_Client/3.5.3/FileZilla_3.5.3_win32-setup.exe/download";
try
{
URL urlw = new URL(url);
URLConnection connect = urlw.openConnection();
size = connect.getContentLength();
String type = connect.getContentType();
String[] names = url.split("/");
String filename = names[names.length-1]+".exe";
in = urlw.openStream();
out = new FileOutputStream(filename, true);
int x;
byte data[] = new byte[1024];
while((x = in.read(data,0,1024)) >= 0)
{
asize += x;
out.write(data, 0, x);
current.setValue((int) (asize/2.1)) ;
current.repaint();
}
out.close();
}
catch (Exception e)
{
}
cancle.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0)
{
try {
out.close();
in.close();
} catch (IOException e)
{
}
}
i nie dziala to moglby mi ktos doradzic jak zrobic przerwanie sciagania? i z progressbarem nie wiem jak zrobic uniwersalna funkcje zeby bylo 100% jak sie skonczy sciaganie bo tutaj dalem asize/2.1 i konczy sie ladnie ale dla tego pliku nie wiem czy dla innych tak samo bedzie jak inna wielkosc beda mialy