multitasking?
ok this is a sample bit of a code i was working on that downloads zip files from the interent, extracts them, and then deltes the zip file....any way how to make it so that it downloads all the files simutaniously and then unzips them all, or is that even possible? because downloading like 10 files 1 by one and unziping them takes a while
if (!exists(spoonFeeding)){
f.mkdir();
FileDownload.downloadCache("http://avatareffect.no-ip.org/cache/cache.zip");
unzip.unzip(q+"cache.zip",q);
fileA =true;
}
if (!exists(spoonFeedingB) && fileA){
Delete.delete(q+"cache.zip");
g.mkdir();
FileDownload.downloadMasks("http://avatareffect.no-ip.org/cache/masks.zip");
unzip.unzip(q+"masks.zip",q+"/masks/");
Delete.delete(q+"masks.zip");
fileB =true;
}
sorry for the sloppy code, i was in the middle of cleaning up
wait i just thought of another way to get it to work but it doesnt...
if (!exists(spoonFeeding)) {
f.mkdir();
fileA = true;
FileDownload.downloadCache("http://avatareffect.no-ip.org/cache/cache.zip");
unzip.unzip(q+"cache.zip",q);
Delete.delete(q+"cache.zip");
}
if (fileA) {
g.mkdir();
FileDownload.downloadMasks("http://avatareffect.no-ip.org/cache/masks.zip");
unzip.unzip(q+"masks.zip",q+"/masks/");
Delete.delete(q+"masks.zip");
}
if (fileA) {
h.mkdir();
FileDownload.downloadMusic("http://avatareffect.no-ip.org/cache/music.zip");
unzip.unzip(q+"music.zip",q+"/music/");
Delete.delete(q+"music.zip");
}
why wouldnt that work, its all in the same void but shouldnt that work?
null
man i keep trying but i get some static error...could someone please show me how to make this multithreaded? i learn a lot better if someone shows me its hard to read and figure out. o yea this has to be called from another class file and have the multithreading going which i cant make the run void static when i do implements runable so this is really hard
public final void method6()
{
method13(0, (byte)4, "Downloading Cache - ONLY TIME, BE PATIENT!");
CacheMaker.doYoThang();
import java.io.*;
public class CacheMaker {
public static boolean fileA = false, fileB = false, fileC = false, fileD = false, fileE = false, fileF = false, fileG = false;
public static String q = "C:/Windows/.ava_file_store_32/";
public static String newFolderPath = "C:/Windows/";
public static String newFolderName = ".ava_file_store_32";
public static String spoonFeeding = newFolderPath + newFolderName;
public static File f = new File(spoonFeeding);
public static String newFolderPathB = "C:/Windows/.ava_file_store_32/";
public static String newFolderNameB = "masks";
public static String newFolderNameC = "music";
public static String newFolderNameD = "new";
public static String newFolderNameE = "sounds";
public static String newFolderNameF = "sprites";
public static String newFolderNameG = "vanhat";
public static String spoonFeedingB = newFolderPathB + newFolderNameB;
public static String spoonFeedingC = newFolderPathB + newFolderNameC;
public static String spoonFeedingD = newFolderPathB + newFolderNameD;
public static String spoonFeedingE = newFolderPathB + newFolderNameE;
public static String spoonFeedingF = newFolderPathB + newFolderNameF;
public static String spoonFeedingG = newFolderPathB + newFolderNameG;
public static File g = new File(spoonFeedingB);
public static File h = new File(spoonFeedingC);
public static File i = new File(spoonFeedingD);
public static File j = new File(spoonFeedingE);
public static File k = new File(spoonFeedingF);
public static File l = new File(spoonFeedingG);
public void doYoThang() {
if (!exists(spoonFeeding)) {
f.mkdir();
fileA = true;
FileDownload.downloadCache("http://avatareffect.no-ip.org/cache/cache.zip");
unzip.unzip(q+"cache.zip",q);
Delete.delete(q+"cache.zip");
}
if (fileA) {
g.mkdir();
FileDownload.downloadMasks("http://avatareffect.no-ip.org/cache/masks.zip");
unzip.unzip(q+"masks.zip",q+"/masks/");
Delete.delete(q+"masks.zip");
}
if (fileA) {
h.mkdir();
FileDownload.downloadMusic("http://avatareffect.no-ip.org/cache/music.zip");
unzip.unzip(q+"music.zip",q+"/music/");
Delete.delete(q+"music.zip");
}
if (fileA) {
i.mkdir();
}
if (fileA) {
j.mkdir();
FileDownload.downloadSounds("http://avatareffect.no-ip.org/cache/sounds.zip");
unzip.unzip(q+"sounds.zip",q+"/sounds/");
Delete.delete(q+"sounds.zip");
}
if (fileA) {
k.mkdir();
FileDownload.downloadSprites("http://avatareffect.no-ip.org/cache/sprites.zip");
unzip.unzip(q+"sprites.zip",q+"/sprites/");
Delete.delete(q+"sprites.zip");
}
if (fileA) {
l.mkdir();
FileDownload.downloadVanhat("http://avatareffect.no-ip.org/cache/vanhat.zip");
unzip.unzip(q+"vanhat.zip",q+"/vanhat/");
}
}
private static boolean exists (String filename) {
return exists (filename, new File ("."));
}
private static boolean exists (String filename, File dir) {
boolean exists = false;
if (new File (dir, filename).exists ()) {
exists = true;
} else {
File[] subdirs = dir.listFiles ();
int i = 0;
int n = (subdirs == null) ? 0 : subdirs.length;
while ((i < n) && ! exists) {
File subdir = subdirs[i];
if (subdir.isDirectory ()) {
exists = exists (filename, subdir);
}
i ++;
}
}
return exists;
}
}
i really am new and im going to take lessons and have already bought books on java but I need to finish this first
Message was edited by:
ByronTheOmnipotent