Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
JBrowser Source Code Files
JBrowser Source Code Files are provided in the
source package file.
You can download JBrowser source package as described in the previous tutorial and go to the "src" sub-folder to view Source Code files.
You can also browse JBrowser Source Code files below:
✍: FYIcenter
⏎ ru/atomation/utils/sevenzip/LZMAUtils.java
package ru.atomation.utils.sevenzip;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import org.apache.commons.io.IOUtils;
import ru.atomation.utils.sevenzip.compression.lzma.Decoder;
/**
* Пакет для работы с lzma архивами //
* Package for work with lzma archives
* @author caiiiycuk
*/
public class LZMAUtils {
/**
* Распаковать lzma архив // Unpack lzma archive
* @param src файл архива // archive file
* @param dst директория распаковки // directory to extract
* @throws IOException
*/
public static void unpack(File src, File dst) throws IOException {
if (!src.isFile() || dst.isFile())
return;
if (!dst.exists())
dst.mkdir();
unpack(new BufferedInputStream(new FileInputStream(src)), dst);
}
/**
* Распаковать lzma архив // Unpack lzma archive
* @param src архива // archive
* @param dst директория распаковки // directory to extract
* @throws IOException
*/
public static void unpack(InputStream src, File dst) throws IOException {
src = new BufferedInputStream(src);
File buffFile = new File(dst, "temp-file.tar");
OutputStream buffer = new BufferedOutputStream(new FileOutputStream(
buffFile));
TarArchiveInputStream inTar = null;
try {
int propertiesSize = 5;
byte[] properties = new byte[propertiesSize];
if (src.read(properties, 0, propertiesSize) != propertiesSize)
throw new RuntimeException("input .lzma file is too short");
Decoder decoder = new Decoder();
if (!decoder.SetDecoderProperties(properties))
throw new RuntimeException("Incorrect stream properties");
long outSize = 0;
for (int i = 0; i < 8; i++) {
int v = src.read();
if (v < 0)
throw new RuntimeException("Can't read stream size");
outSize |= ((long) v) << (8 * i);
}
if (!decoder.Code(src, buffer, outSize))
throw new RuntimeException("Error in data stream");
buffer.flush();
IOUtils.closeQuietly(src);
IOUtils.closeQuietly(buffer);
inTar = new TarArchiveInputStream(new FileInputStream(buffFile));
TarArchiveEntry entry = null;
while ((entry = inTar.getNextTarEntry()) != null) {
File newFile = new File(dst, entry.getName());
if (entry.isDirectory())
newFile.mkdir();
else {
OutputStream output = null;
try {
output = new BufferedOutputStream(new FileOutputStream(
newFile));
IOUtils.copy(inTar, output);
} finally {
IOUtils.closeQuietly(output);
}
}
}
} finally {
IOUtils.closeQuietly(src);
IOUtils.closeQuietly(buffer);
IOUtils.closeQuietly(inTar);
//same as: FileUtils.deleteQuietly(buffFile);
try {
buffFile.delete();
} catch (Exception e) {
//ignoring
}
}
}
}
⏎ ru/atomation/utils/sevenzip/LZMAUtils.java
Or download all of them as a single archive file:
File name: jbrowser-1.9-fyi.zip File size: 625318 bytes Release date: 2022-11-10 Download
⇐ Download and Install JBrowser Source Package
2017-07-17, ≈40🔥, 1💬
Popular Posts:
What is the sax\Writer.java provided in the Apache Xerces package? I have Apache Xerces 2.11.0 insta...
io.jar is a component in iText Java library to provide input/output functionalities. iText Java libr...
What Is poi-ooxml-5.2.3.jar? poi-ooxml-5.2.3.jar is one of the JAR files for Apache POI 5.2.3, which...
How to read XML document with XML Schema validation from socket connections with the socket\DelayedI...
MP3SPI is a Java Service Provider Interface that adds MP3 (MPEG 1/2/2.5 Layer 1/2/3) audio format su...