Latest WIP

This commit is contained in:
nossr50 2011-09-06 02:56:47 -07:00
parent 4c6647e332
commit 0d527e282f

View File

@ -6,6 +6,7 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.jar.JarEntry; import java.util.jar.JarEntry;
@ -54,25 +55,25 @@ public class SpoutStuff
public static void writeFile(String theFileName, String theFilePath) public static void writeFile(String theFileName, String theFilePath)
{ {
try { try {
File currentFile = new File("plugins/mcMMO/Resources/"+theFilePath+theFileName); File currentFile = new File("plugins/mcMMO/Resources/"+theFilePath+theFileName);
//System.out.println(theFileName); @SuppressWarnings("static-access")
@SuppressWarnings("static-access") JarFile jar = new JarFile(plugin.mcmmo);
JarFile jar = new JarFile(plugin.mcmmo); JarEntry entry = jar.getJarEntry("resources/"+theFileName);
JarEntry entry = jar.getJarEntry("resources/"+theFileName); InputStream is = jar.getInputStream(entry);
InputStream is = jar.getInputStream(entry); byte[] buf = new byte[2048];
byte[] buf = new byte[(int)entry.getSize()]; int nbRead;
is.read(buf, 0, buf.length); OutputStream os = new BufferedOutputStream(new FileOutputStream(currentFile));
FileOutputStream os = new FileOutputStream(currentFile); while((nbRead = is.read(buf)) != -1) {
os.write(buf); os.write(buf, 0, nbRead);
os.close(); }
} catch (FileNotFoundException e) { os.flush();
// TODO Auto-generated catch block os.close();
e.printStackTrace(); } catch (FileNotFoundException e) {
} catch (IOException e) { e.printStackTrace();
// TODO Auto-generated catch block } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
public static void extractFiles() public static void extractFiles()