Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
com.aayushatharva.brotli4j:brotli4j-parent
Brotli4j provides Brotli compression and decompression for Java.
Module | Architecture | Tested On |
---|---|---|
Windows (Windows Server 2022) | x64 | JDK 1.8, JDK 11, JDK 17, JDK 21 |
Windows 11 | Aarch64 | JDK 11 |
Linux (CentOS 6) | x64 | JDK 1.8, JDK 11, JDK 17, JDK 21 |
Linux (Ubuntu 18.04) | Aarch64 | JDK 1.8, JDK 11, JDK 17, JDK 21 |
Linux (Ubuntu 18.04) | ARMv7 | JDK 1.8, JDK 11, JDK 17 |
Linux (Ubuntu 18.04) | s390x | JDK 1.8, JDK 11 |
Linux (Ubuntu 18.04) | ppc64le | JDK 1.8, JDK 11 |
Linux (Ubuntu 20.04) | RISC-v64 | JDK 1.8, JDK 11, JDK 17, JDK 21 |
macOS (Catalina) | x64 | JDK 1.8, JDK 11, JDK 17, JDK 21 |
macOS (Catalina) | Aarch64 | JDK 1.8, JDK 11, JDK 17, JDK 21 |
For maven, the natives will import automatically by your system family and architecture.
<dependency>
<groupId>com.aayushatharva.brotli4j</groupId>
<artifactId>brotli4j</artifactId>
<version>1.17.0</version>
</dependency>
For gradle, we have to write some logic to import native automatically. Of course, you can add native(s) as dependency manually also.
import org.gradle.nativeplatform.platform.internal.Architectures
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
import org.gradle.nativeplatform.operatingsystem.OperatingSystem
val brotliVersion = "1.17.0"
val operatingSystem: OperatingSystem = DefaultNativePlatform.getCurrentOperatingSystem()
repositories {
mavenCentral()
}
dependencies {
implementation("com.aayushatharva.brotli4j:brotli4j:$brotliVersion")
runtimeOnly(
"com.aayushatharva.brotli4j:native-" +
if (operatingSystem.isWindows) {
if (DefaultNativePlatform.getCurrentArchitecture().isArm()) {
"windows-aarch64"
} else {
"windows-x86_64"
}
} else if (operatingSystem.isMacOsX) {
if (DefaultNativePlatform.getCurrentArchitecture().isArm()) {
"osx-aarch64"
} else {
"osx-x86_64"
}
} else if (operatingSystem.isLinux) {
if (Architectures.ARM_V7.isAlias(DefaultNativePlatform.getCurrentArchitecture().name)) {
"linux-armv7"
} else if (Architectures.AARCH64.isAlias(DefaultNativePlatform.getCurrentArchitecture().name)) {
"linux-aarch64"
} else if (Architectures.X86_64.isAlias(DefaultNativePlatform.getCurrentArchitecture().name)) {
"linux-x86_64"
} else if (Architectures.S390X.isAlias(DefaultNativePlatform.getCurrentArchitecture().name)) {
"linux-s390x"
} else if (Architectures.RISCV_64.isAlias(DefaultNativePlatform.getCurrentArchitecture().name)) {
"linux-riscv64"
} else if (Architectures.PPC64LE.isAlias(DefaultNativePlatform.getCurrentArchitecture().name)) {
"linux-ppc64le"
} else {
throw IllegalStateException("Unsupported architecture: ${DefaultNativePlatform.getCurrentArchitecture().name}")
}
} else {
throw IllegalStateException("Unsupported operating system: $operatingSystem")
} + ":$brotliVersion"
)
}
import org.gradle.nativeplatform.platform.internal.Architectures
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
def brotliVersion = "1.17.0"
def operatingSystem = DefaultNativePlatform.getCurrentOperatingSystem()
def currentArchitecture = DefaultNativePlatform.getCurrentArchitecture()
repositories {
mavenCentral()
}
dependencies {
implementation "com.aayushatharva.brotli4j:brotli4j:$brotliVersion"
runtimeOnly("""com.aayushatharva.brotli4j:native-${
if (operatingSystem.isWindows())
if (currentArchitecture.isX86_64()) "windows-x86_64"
else if (currentArchitecture.isArm()) "windows-aarch64"
else
throw new IllegalStateException("Unsupported architecture: ${currentArchitecture.getName()}");
else if (operatingSystem.isMacOsX())
if (currentArchitecture.isArm()) "osx-aarch64"
else "osx-x86_64"
else if (operatingSystem.isLinux())
if (currentArchitecture.isAARCH64()) "linux-aarch64"
else if (currentArchitecture.isX86_64()) "linux-x86_64"
else if (currentArchitecture.isARM_V7()) "linux-armv7"
else if (currentArchitecture.isPPC64LE()) "linux-ppc64le"
else if (currentArchitecture.isS390X()) "linux-s390x"
else if (currentArchitecture.isRISCV64()) "linux-riscv64"
else
throw new IllegalStateException("Unsupported architecture: ${currentArchitecture.getName()}");
else
throw new IllegalStateException("Unsupported operating system: $operatingSystem");
}:$brotliVersion""")
}
Call Brotli4jLoader.ensureAvailability()
in your application once before using Brotli4j. This will load
Brotli4j native library automatically using automatic dependency resolution.
However, its possible to load native library manually from custom path by specifying System Property "brotli4j.library.path"
.
public class Example {
public static void main(String[] args) {
// Load the native library
Brotli4jLoader.ensureAvailability();
// Compress data and get output in byte array
byte[] compressed = Encoder.compress("Meow".getBytes());
// Decompress data and get output in DirectDecompress
DirectDecompress directDecompress = Decoder.decompress(compressed); // or DirectDecompress.decompress(compressed);
if (directDecompress.getResultStatus() == DecoderJNI.Status.DONE) {
System.out.println("Decompression Successful: " + new String(directDecompress.getDecompressedData()));
} else {
System.out.println("Some Error Occurred While Decompressing");
}
}
}
public class Example {
public static void main(String[] args) {
// Load the native library
Brotli4jLoader.ensureAvailability();
FileInputStream inFile = new FileInputStream(filePath);
FileOutputStream outFile = new FileOutputStream(filePath + ".br");
Encoder.Parameters params = new Encoder.Parameters().setQuality(4);
BrotliOutputStream brotliOutputStream = new BrotliOutputStream(outFile, params);
int read = inFile.read();
while (read > -1) {
brotliOutputStream.write(read);
read = inFile.read();
}
// Close the BrotliOutputStream. This also closes the FileOutputStream.
brotliOutputStream.close();
inFile.close();
}
}
public class Example {
public static void main(String[] args) {
// Load the native library
Brotli4jLoader.ensureAvailability();
FileInputStream inFile = new FileInputStream(filePath);
FileOutputStream outFile = new FileOutputStream(decodedfilePath);
BrotliInputStream brotliInputStream = new BrotliInputStream(inFile);
int read = brotliInputStream.read();
while (read > -1) {
outFile.write(read);
read = brotliInputStream.read();
}
// Close the BrotliInputStream. This also closes the FileInputStream.
brotliInputStream.close();
outFile.close();
}
}
JProfiler is supporting Brotli4J with its full-featured Java Profiler. JProfiler's intuitive UI helps you resolve performance bottlenecks, pin down memory leaks and understand threading issues. Click below to know more:
FAQs
Brotli4j provides Brotli compression and decompression for Java.
We found that com.aayushatharva.brotli4j:brotli4j-parent demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.