Fix all warnings
Add and make use of Lombok Remove Mojang API Remove ZipFileUtils Remove StreamTools in favor of Apache IOUtils Keyframe should be abstract all derivatives final Replace clone in Keyframe with copy Move some constants from GuiReplaySetttings to GuiConstants
This commit is contained in:
@@ -6,9 +6,6 @@ public class EmailAddressUtils {
|
||||
public static boolean isValidEmailAddress(String mail) {
|
||||
try {
|
||||
String[] spl1 = mail.split("@");
|
||||
String[] spl2 = spl1[1].split("\\.");
|
||||
String suffix = spl2[1];
|
||||
|
||||
return spl1[0].equals(URLEncoder.encode(spl1[0], "UTF-8")) && spl1[1].equals(URLEncoder.encode(spl1[1], "UTF-8"));
|
||||
} catch(Exception e) {
|
||||
return false;
|
||||
|
||||
@@ -11,8 +11,8 @@ public class MouseUtils {
|
||||
|
||||
public static Point getMousePos() {
|
||||
Point scaled = getScaledDimensions();
|
||||
int width = (int) scaled.getX();
|
||||
int height = (int) scaled.getY();
|
||||
int width = scaled.getX();
|
||||
int height = scaled.getY();
|
||||
|
||||
final int mouseX = (Mouse.getX() * width / mc.displayWidth);
|
||||
final int mouseY = (height - Mouse.getY() * height / mc.displayHeight);
|
||||
@@ -20,17 +20,6 @@ public class MouseUtils {
|
||||
return new Point(mouseX, mouseY);
|
||||
}
|
||||
|
||||
public static void moveMouse(int mouseX, int mouseY) {
|
||||
Point scaled = getScaledDimensions();
|
||||
int width = (int) scaled.getX();
|
||||
int height = (int) scaled.getY();
|
||||
|
||||
int x = (int)Math.round(((mouseX+0.5)*mc.displayWidth)/width);
|
||||
int y = (mouseY*mc.displayHeight)/height;
|
||||
|
||||
Mouse.setCursorPosition(x, y);
|
||||
}
|
||||
|
||||
public static Point getScaledDimensions() {
|
||||
ScaledResolution sr = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
||||
final int width = sr.getScaledWidth();
|
||||
|
||||
@@ -14,10 +14,7 @@ import net.minecraft.network.EnumConnectionState;
|
||||
import net.minecraft.network.EnumPacketDirection;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.server.S01PacketJoinGame;
|
||||
import net.minecraft.network.play.server.S08PacketPlayerPosLook;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import java.io.*;
|
||||
@@ -31,29 +28,26 @@ public class ReplayFileIO {
|
||||
|
||||
private static final PacketSerializer packetSerializer = new PacketSerializer(EnumPacketDirection.CLIENTBOUND);
|
||||
private static final byte[] uniqueBytes = new byte[]{0, 1, 1, 2, 3, 5, 8};
|
||||
private static File lastReplayFile = null;
|
||||
private static boolean lastContainsJoinPacket = false;
|
||||
|
||||
public static File getRenderFolder() {
|
||||
public static File getRenderFolder() throws IOException {
|
||||
File folder = new File(ReplayMod.replaySettings.getRenderPath());
|
||||
folder.mkdirs();
|
||||
FileUtils.forceMkdir(folder);
|
||||
return folder;
|
||||
}
|
||||
|
||||
public static File getReplayFolder() {
|
||||
public static File getReplayFolder() throws IOException {
|
||||
String path = ReplayMod.replaySettings.getRecordingPath();
|
||||
File folder = new File(path);
|
||||
folder.mkdirs();
|
||||
FileUtils.forceMkdir(folder);
|
||||
return folder;
|
||||
}
|
||||
|
||||
public static List<File> getAllReplayFiles() {
|
||||
List<File> files = new ArrayList<File>();
|
||||
File folder = getReplayFolder();
|
||||
for(File file : folder.listFiles()) {
|
||||
if(("." + FilenameUtils.getExtension(file.getAbsolutePath())).equals(ReplayFile.ZIP_FILE_EXTENSION)) {
|
||||
files.add(file);
|
||||
}
|
||||
try {
|
||||
files.addAll(FileUtils.listFiles(getReplayFolder(), new String[]{"mcpr"}, false));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return files;
|
||||
}
|
||||
@@ -62,10 +56,6 @@ public class ReplayFileIO {
|
||||
Map<String, File> resourcePacks, Map<Integer, String> resourcePackRequests) throws IOException {
|
||||
byte[] buffer = new byte[1024];
|
||||
|
||||
if(!replayFile.exists()) {
|
||||
replayFile.createNewFile();
|
||||
}
|
||||
|
||||
FileOutputStream fos = new FileOutputStream(replayFile);
|
||||
ZipOutputStream zos = new ZipOutputStream(fos);
|
||||
|
||||
@@ -113,59 +103,6 @@ public class ReplayFileIO {
|
||||
zos.close();
|
||||
}
|
||||
|
||||
public static ReplayMetaData getMetaData(File replayFile) throws IOException {
|
||||
ReplayFile file = new ReplayFile(replayFile);
|
||||
try {
|
||||
return file.metadata().get();
|
||||
} finally {
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param replayFile
|
||||
* @return Whether the given Replay File contains a {@link S01PacketJoinGame}.
|
||||
*/
|
||||
public static boolean containsJoinPacket(File replayFile) {
|
||||
DataInputStream dis = null;
|
||||
if(replayFile == lastReplayFile) {
|
||||
return lastContainsJoinPacket;
|
||||
}
|
||||
ReplayFile file = null;
|
||||
|
||||
lastReplayFile = replayFile;
|
||||
lastContainsJoinPacket = false;
|
||||
try {
|
||||
file = new ReplayFile(replayFile);
|
||||
dis = new DataInputStream(file.recording().get());
|
||||
PacketData pd = readPacketData(dis);
|
||||
while(dis.available() > 0) {
|
||||
Packet p = deserializePacket(pd.getByteArray());
|
||||
if(p instanceof S01PacketJoinGame) {
|
||||
lastContainsJoinPacket = true;
|
||||
return lastContainsJoinPacket;
|
||||
}
|
||||
if(p instanceof S08PacketPlayerPosLook) {
|
||||
lastContainsJoinPacket = false;
|
||||
return lastContainsJoinPacket;
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if(dis != null) {
|
||||
dis.close();
|
||||
}
|
||||
if (file != null) {
|
||||
file.close();
|
||||
}
|
||||
} catch(Exception ignored) {}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static PacketData readPacketData(DataInputStream dis) throws IOException {
|
||||
int timestamp = dis.readInt();
|
||||
int bytes = dis.readInt();
|
||||
@@ -209,135 +146,27 @@ public class ReplayFileIO {
|
||||
out.write(pd.getByteArray());
|
||||
}
|
||||
|
||||
public static int getWrittenByteSize(PacketData pd) {
|
||||
return (2 * 4) + pd.getByteArray().length;
|
||||
}
|
||||
|
||||
public static void writePackets(Collection<PacketData> p, DataOutput out) throws IOException {
|
||||
for(PacketData pd : p) {
|
||||
writePacket(pd, out);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param replayFile The File to reverse
|
||||
* @param outputFile The File to save the reversed Packets in
|
||||
* @param seekJoinPacket Whether a {@link S01PacketJoinGame} should be seeked in the Replay File. If containsJoinPacket is being
|
||||
* called with the same File directly afterwards, this will reduce the amount of calculations. Only use if needed,
|
||||
* because this consumes a significant amount of time!
|
||||
* @param boundaries Two timestamps which make a boundary for excluded Packets
|
||||
* @return Whether the action was successful
|
||||
*/
|
||||
public static boolean reversePackets(File replayFile, File outputFile, boolean seekJoinPacket, int... boundaries) {
|
||||
lastReplayFile = replayFile;
|
||||
lastContainsJoinPacket = false;
|
||||
|
||||
RandomAccessFile raf = null;
|
||||
DataInputStream dis = null;
|
||||
ReplayFile file = null;
|
||||
|
||||
boolean bounds = false;
|
||||
int lower = 0, upper = 0;
|
||||
if(boundaries.length >= 2) {
|
||||
if(boundaries[0] > boundaries[1]) {
|
||||
upper = boundaries[0];
|
||||
lower = boundaries[1];
|
||||
} else {
|
||||
upper = boundaries[1];
|
||||
lower = boundaries[0];
|
||||
}
|
||||
}
|
||||
try {
|
||||
if(!outputFile.exists()) {
|
||||
outputFile.createNewFile();
|
||||
}
|
||||
raf = new RandomAccessFile(outputFile, "rw");
|
||||
file = new ReplayFile(replayFile);
|
||||
|
||||
dis = new DataInputStream(file.recording().get());
|
||||
long fileLength = file.recordingEntry().getSize();
|
||||
|
||||
raf.setLength(fileLength);
|
||||
|
||||
long pointerBefore = fileLength;
|
||||
|
||||
while(dis.available() > 0) {
|
||||
try {
|
||||
PacketData pd = readPacketData(dis);
|
||||
|
||||
boolean write = true;
|
||||
if(bounds) {
|
||||
if(pd.getTimestamp() < lower || pd.getTimestamp() > upper) {
|
||||
write = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(write) {
|
||||
if(seekJoinPacket && !lastContainsJoinPacket) {
|
||||
Packet p = deserializePacket(pd.getByteArray());
|
||||
if(p instanceof S01PacketJoinGame) lastContainsJoinPacket = true;
|
||||
}
|
||||
pointerBefore = pointerBefore - getWrittenByteSize(pd);
|
||||
raf.seek(pointerBefore);
|
||||
writePacket(pd, raf);
|
||||
}
|
||||
} catch(EOFException e) {
|
||||
e.printStackTrace();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if(raf != null) {
|
||||
raf.close();
|
||||
}
|
||||
if(dis != null) {
|
||||
dis.close();
|
||||
}
|
||||
if(file != null) {
|
||||
file.close();
|
||||
}
|
||||
} catch(Exception ignored) {}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final Gson gson = new Gson();
|
||||
|
||||
public static void writeKeyframeRegistryToFile(KeyframeSet[] keyframeRegistry, File file) throws IOException {
|
||||
file.mkdirs();
|
||||
file.createNewFile();
|
||||
|
||||
String json = gson.toJson(keyframeRegistry);
|
||||
private static void write(Object obj, File file) throws IOException {
|
||||
String json = gson.toJson(obj);
|
||||
FileUtils.write(file, json);
|
||||
}
|
||||
|
||||
public static void writePlayerVisibilityToFile(PlayerVisibility visibility, File file) throws IOException {
|
||||
file.mkdirs();
|
||||
file.createNewFile();
|
||||
|
||||
String json = gson.toJson(visibility);
|
||||
FileUtils.write(file, json);
|
||||
public static void write(KeyframeSet[] keyframeRegistry, File file) throws IOException {
|
||||
write((Object) keyframeRegistry, file);
|
||||
}
|
||||
|
||||
public static void writeReplayMetaDataToFile(ReplayMetaData metaData, File file) throws IOException {
|
||||
file.mkdirs();
|
||||
file.createNewFile();
|
||||
|
||||
String json = gson.toJson(metaData);
|
||||
FileUtils.write(file, json);
|
||||
public static void write(PlayerVisibility visibility, File file) throws IOException {
|
||||
write((Object) visibility, file);
|
||||
}
|
||||
|
||||
public static void writeMarkersToFile(MarkerKeyframe[] markers, File file) throws IOException {
|
||||
file.mkdirs();
|
||||
file.createNewFile();
|
||||
public static void write(ReplayMetaData metaData, File file) throws IOException {
|
||||
write((Object) metaData, file);
|
||||
}
|
||||
|
||||
String json = gson.toJson(markers);
|
||||
FileUtils.write(file, json);
|
||||
public static void write(MarkerKeyframe[] markers, File file) throws IOException {
|
||||
write((Object) markers, file);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -406,7 +235,7 @@ public class ReplayFileIO {
|
||||
// Complete the ZIP file
|
||||
out.close();
|
||||
|
||||
zipFile.delete();
|
||||
tempFile.renameTo(zipFile);
|
||||
FileUtils.forceDelete(zipFile);
|
||||
FileUtils.moveFile(tempFile, zipFile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,226 +0,0 @@
|
||||
/* Leichtathletik Daten Verarbeitung (LDV)
|
||||
* Copyright (C) 2004 Marc Schunk
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
package eu.crushedpixel.replaymod.utils;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
/**
|
||||
* @author Marc Schunk, created on 21.06.2004
|
||||
* <p/>
|
||||
* A Class to provide helpers of commonly user operations with binary
|
||||
* and character Streams, such as read to an OutputStream/Writer,
|
||||
* String, ByteArray. In addition streams can be compressed.
|
||||
*/
|
||||
|
||||
public class StreamTools {
|
||||
|
||||
public static final String[] umlauteString = {"&", "ß", "ä",
|
||||
"Ä", "ö", "Ö", "ü", "Ü", "ß"};
|
||||
public static final String[] umlauteReplacement = {"&", "ß", "ä", "Ä", "ö",
|
||||
"Ö", "ü", "Ü", "ß"};
|
||||
|
||||
/**
|
||||
* Checks weather the given array is contained in the first array
|
||||
*
|
||||
* @param ar1 - the containing array
|
||||
* @param index1 - the index where the search starts
|
||||
* @param ar2 - the array that schould be contained
|
||||
* @return - true of ar2 is contained in ar1
|
||||
*/
|
||||
public static final boolean arrayMatch(char[] ar1, int index1, char[] ar2) {
|
||||
if((ar1.length - index1 - ar2.length) < 0)
|
||||
return false;
|
||||
for(int i = 0; i < ar2.length; i++) {
|
||||
if(ar1[index1 + i] != ar2[i])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads inStream completly and writes it to outStream. Streams will not be
|
||||
* closed.
|
||||
*
|
||||
* @param inStream - an InputStream to be read completely
|
||||
* @param outStream - the destination Stream
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void readStream(InputStream inStream, OutputStream outStream)
|
||||
throws IOException {
|
||||
byte[] buffer = new byte[4096];
|
||||
int len = 0;
|
||||
while((len = inStream.read(buffer, 0, buffer.length)) > -1) {
|
||||
outStream.write(buffer, 0, len);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads inStream completly into an byte[]. Streams will not be closed.
|
||||
*
|
||||
* @param inStream - an InputStream to be read completely
|
||||
* @param outStream - the destination Stream
|
||||
* @throws IOException
|
||||
*/
|
||||
public static byte[] readStream(InputStream inStream) throws IOException {
|
||||
byte[] buffer = new byte[4096];
|
||||
int len = 0;
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
while((len = inStream.read(buffer, 0, buffer.length)) > -1) {
|
||||
baos.write(buffer, 0, len);
|
||||
}
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the given Steam into an String *
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String readStreamtoString(InputStream inStream)
|
||||
throws IOException {
|
||||
StringWriter sw = new StringWriter();
|
||||
InputStreamReader isr = new InputStreamReader(inStream);
|
||||
|
||||
char[] buffer = new char[4096];
|
||||
int len = 0;
|
||||
while((len = isr.read(buffer, 0, buffer.length)) > -1) {
|
||||
sw.write(buffer, 0, len);
|
||||
}
|
||||
return sw.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the given Steam into an String using the given encoding
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String readStreamtoString(InputStream inStream, String charSet)
|
||||
throws IOException {
|
||||
StringWriter sw = new StringWriter();
|
||||
InputStreamReader isr = new InputStreamReader(inStream, charSet);
|
||||
|
||||
char[] buffer = new char[4096];
|
||||
int len = 0;
|
||||
while((len = isr.read(buffer, 0, buffer.length)) > -1) {
|
||||
sw.write(buffer, 0, len);
|
||||
}
|
||||
return sw.toString();
|
||||
}
|
||||
|
||||
public static String stripComments(String inString, String newLineDelimiter)
|
||||
throws IOException {
|
||||
StringWriter sw = new StringWriter();
|
||||
// use both windows and linux/unix line seperators to be independent of the file orgin
|
||||
String[] lines = inString.split("\r\n|\n");
|
||||
for(String line : lines) {
|
||||
if((line.indexOf("#") == -1) && (line.trim().length() > 0)) {
|
||||
sw.append(line).append(newLineDelimiter);
|
||||
}
|
||||
}
|
||||
return sw.toString();
|
||||
}
|
||||
|
||||
public static String replaceSpecialCharacters(String s) {
|
||||
for(int i = 0; i < umlauteString.length; i++) {
|
||||
s = s.replaceAll(umlauteString[i], umlauteReplacement[i]);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the given Stream in an byte[]. Stream is compressed on the fly.
|
||||
* Streams will not be closed.
|
||||
*
|
||||
* @param inStream - an InputStream to be read completely
|
||||
* @param outStream - the destination Stream
|
||||
* @throws IOException
|
||||
*/
|
||||
public static byte[] compressStreamToByteArray(InputStream inStream)
|
||||
throws IOException {
|
||||
byte[] buffer = new byte[4096];
|
||||
int len = 0;
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
|
||||
GZIPOutputStream zos = new GZIPOutputStream(baos);
|
||||
while((len = inStream.read(buffer, 0, buffer.length)) > -1) {
|
||||
zos.write(buffer, 0, len);
|
||||
}
|
||||
zos.close();
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the given Stream in an byte[]. Stream is compressed on the fly.
|
||||
* Streams will not be closed.
|
||||
*
|
||||
* @param inStream - an InputStream to be read completely
|
||||
* @param outStream - the destination Stream
|
||||
* @throws IOException
|
||||
*/
|
||||
public static byte[] compress(byte[] uncompressed) throws IOException {
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(uncompressed);
|
||||
return compressStreamToByteArray(bais);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the given Stream in an byte[]. Stream is decompressed on the fly.
|
||||
* Thus, the input stream should contain compressed content. Streams will
|
||||
* not be closed.
|
||||
*
|
||||
* @param inStream - an InputStream to be read completely
|
||||
* @param outStream - the destination Stream
|
||||
* @throws IOException
|
||||
*/
|
||||
public static byte[] decompressStreamToByteArray(InputStream inStream)
|
||||
throws IOException {
|
||||
byte[] buffer = new byte[4096];
|
||||
int len = 0;
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
GZIPInputStream gzis = new GZIPInputStream(inStream);
|
||||
while((len = gzis.read(buffer, 0, buffer.length)) > -1) {
|
||||
baos.write(buffer, 0, len);
|
||||
}
|
||||
inStream.close();
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
public static byte[] decompress(byte[] compressed) throws IOException {
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(compressed);
|
||||
return decompressStreamToByteArray(bais);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the given Steam into an String *
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String readReaderToString(Reader reader) throws IOException {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
char[] buffer = new char[4096];
|
||||
int len = 0;
|
||||
while((len = reader.read(buffer, 0, buffer.length)) > -1) {
|
||||
sb.append(buffer, 0, len);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package eu.crushedpixel.replaymod.utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
public class ZipFileUtils {
|
||||
|
||||
public static void deleteZipEntry(File zipFile,
|
||||
String[] files) throws IOException {
|
||||
// get a temp file
|
||||
File tempFile = File.createTempFile(zipFile.getName(), null);
|
||||
// delete it, otherwise you cannot rename your existing zip to it.
|
||||
tempFile.delete();
|
||||
tempFile.deleteOnExit();
|
||||
boolean renameOk = zipFile.renameTo(tempFile);
|
||||
if(!renameOk) {
|
||||
throw new RuntimeException("could not rename the file " + zipFile.getAbsolutePath() + " to " + tempFile.getAbsolutePath());
|
||||
}
|
||||
byte[] buf = new byte[1024];
|
||||
|
||||
ZipInputStream zin = new ZipInputStream(new FileInputStream(tempFile));
|
||||
ZipOutputStream zout = new ZipOutputStream(new FileOutputStream(zipFile));
|
||||
|
||||
ZipEntry entry = zin.getNextEntry();
|
||||
while(entry != null) {
|
||||
String name = entry.getName();
|
||||
boolean toBeDeleted = false;
|
||||
for(String f : files) {
|
||||
if(f.equals(name)) {
|
||||
toBeDeleted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!toBeDeleted) {
|
||||
// Add ZIP entry to output stream.
|
||||
zout.putNextEntry(new ZipEntry(name));
|
||||
// Transfer bytes from the ZIP file to the output file
|
||||
int len;
|
||||
while((len = zin.read(buf)) > 0) {
|
||||
zout.write(buf, 0, len);
|
||||
}
|
||||
}
|
||||
entry = zin.getNextEntry();
|
||||
}
|
||||
// Close the streams
|
||||
zin.close();
|
||||
// Compress the files
|
||||
// Complete the ZIP file
|
||||
zout.close();
|
||||
tempFile.delete();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user