https://github.com/fdero/bits4j
A simple java library to perform low-level bits manipulations and conversions (hosted on maven-central)
https://github.com/fdero/bits4j
bit-conversion bit-converter bit-manipulation java java-21 low-level
Last synced: 9 months ago
JSON representation
A simple java library to perform low-level bits manipulations and conversions (hosted on maven-central)
- Host: GitHub
- URL: https://github.com/fdero/bits4j
- Owner: fDero
- License: mit
- Created: 2024-10-01T01:32:54.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-10-24T16:46:40.000Z (about 1 year ago)
- Last Synced: 2025-03-25T21:11:49.134Z (9 months ago)
- Topics: bit-conversion, bit-converter, bit-manipulation, java, java-21, low-level
- Language: Java
- Homepage:
- Size: 51.8 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

[](https://img.shields.io/maven-central/v/io.github.fdero/bits4j)
[](https://javadoc.io/doc/io.github.fdero/bits4j)
# Bits4j
A simple user-friendly library to perform bits manipulations in java. You might find this useful if you're implementing
compression/encryption algorithms.
### Include bits4j in your projects
You can include the latest version of `bits4j` in your maven project adding the following dependency tag:
```xml
io.github.fdero
bits4j
LATEST
```
### Brief overview
- This library comes with the `BitValue` enum, wich has two values, `BitValue.ZERO` and `BitValue.ONE`.
- You can create a `BitList` (an efficient implementation of `List`) to store them.
- You can use `BitListConversions` to convert between `byte`,`int`,`long`,`String` and `BitList`.
- The `BitReader` is a wrapper around `InputStream` that allows the user to read bit by bit.
- The `BitWriter` is a wrapper around `OutputStream` that allows the user to write bit by bit.
- The `flush` method of `BitWriter` ignores the last bits if they are not part of a byte.
- The `BitWriter` has a `addPadding` method that adds zeros to complete the byte.
- The `BitListInputStream` it's an implementation of `InputStream` that reads from a `List`.
- The `BitListOutputStream` it's an implementation of `OutputStream` that writes to `List`.