Hey people, could anybody fix this for me? I get this error when I compile
, If any of you guys fix ill release auto server updating when you restart I just cant seem to fix this class...
Code:
Update.java:126: not a statement
exception;
^
1 error
Press any key to continue . . .
Code:
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
public class Update extends Thread
{
private String homeDir;
private String saveAs;
private String urlLoc;
private boolean checkProgress;
public static void main(String args[])
{
}
public Update(String s, String s1, String s2)
{
homeDir = s2;
saveAs = (new StringBuilder()).append(s2).append(s1).toString();
urlLoc = s;
if(!(new File(s2)).exists())
{
(new File(s2)).mkdir();
}
if(downloadFile())
{
unZipFile();
deleteFile();
} else
{
System.out.println("error");
deleteFile();
}
}
private void writeStream(InputStream inputstream, OutputStream outputstream)
throws IOException
{
byte abyte0[] = new byte[1024];
int i;
while((i = inputstream.read(abyte0)) >= 0)
{
outputstream.write(abyte0, 0, i);
}
inputstream.close();
outputstream.close();
}
private void unZipFile()
{
try
{
ZipFile zipfile = new ZipFile(saveAs);
for(Enumeration enumeration = zipfile.entries(); enumeration.hasMoreElements();)
{
ZipEntry zipentry = (ZipEntry)enumeration.nextElement();
if(zipentry.isDirectory())
{
if(checkProgress)
{
System.out.println((new StringBuilder()).append("Creating Directory: ").append(zipentry.getName()).toString());
}
(new File((new StringBuilder()).append(homeDir).append(zipentry.getName()).toString())).mkdir();
} else
{
if(checkProgress)
{
System.out.println((new StringBuilder()).append("Extracting File: ").append(zipentry.getName()).toString());
}
writeStream(zipfile.getInputStream(zipentry), new BufferedOutputStream(new FileOutputStream((new StringBuilder()).append(homeDir).append(zipentry.getName()).toString())));
}
}
zipfile.close();
}
catch(Exception exception)
{
exception.printStackTrace();
}
}
private void deleteFile()
{
try
{
File file = new File(saveAs);
file.delete();
}
catch(Exception exception)
{
exception.printStackTrace();
}
}
private boolean downloadFile()
{
long l;
File file;
if(checkProgress)
{
System.out.println((new StringBuilder()).append("Downloading ").append(saveAs).append("...").toString());
}
URLConnection urlconnection = (new URL(urlLoc)).openConnection();
urlconnection.setRequestProperty("User-Agent", "Mozilla");
l = urlconnection.getContentLength();
FileOutputStream fileoutputstream = new FileOutputStream(saveAs);
BufferedOutputStream bufferedoutputstream = new BufferedOutputStream(fileoutputstream);
writeStream(urlconnection.getInputStream(), bufferedoutputstream);
fileoutputstream.close();
bufferedoutputstream.close();
file = new File(saveAs);
if(l != file.length())
{
return false;
}
if(checkProgress)
{
System.out.println((new StringBuilder()).append(saveAs).append(" downloaded...").toString());
}
return true;
Exception exception;
exception;
System.out.println(exception);
return false;
}
}