https://github.com/wasabithumb/vario
Java 8 library for reading/writing variable-length primitives
https://github.com/wasabithumb/vario
java variable-length varint vf128
Last synced: 26 days ago
JSON representation
Java 8 library for reading/writing variable-length primitives
- Host: GitHub
- URL: https://github.com/wasabithumb/vario
- Owner: WasabiThumb
- License: apache-2.0
- Created: 2025-05-03T18:23:17.000Z (29 days ago)
- Default Branch: master
- Last Pushed: 2025-05-03T18:31:16.000Z (29 days ago)
- Last Synced: 2025-05-03T19:34:24.852Z (29 days ago)
- Topics: java, variable-length, varint, vf128
- Language: Java
- Homepage:
- Size: 88.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
#
vario
Java 8 library for reading/writing variable-length primitives (VarInt, VarUInt, VarFloat, VarDouble)## Quick Start
### Declaration
#### Gradle (Kotlin)
```kotlin
dependencies {
implementation("io.github.wasabithumb:vario:0.1.0")
}
```#### Gradle (Groovy)
```groovy
dependencies {
implementation 'io.github.wasabithumb:vario:0.1.0'
}
```#### Maven
```xml
io.github.wasabithumb
vario
0.1.0
compile
```
### Basic Usage
```java
VarDataOutputStream vdos = new VarDataOutputStream(os);// Signed 32-bit integers
vdos.writeVarInt32(100);
vdos.writeVarInt32(-100);// Unsigned 32-bit integers
vdos.writeVarUInt32(50);
vdos.writeVarUInt32(200);// Signed 64-bit integers
vdos.writeVarInt64(Long.MIN_VALUE);
vdos.writeVarInt64(Long.MAX_VALUE);// Unsigned 64-bit integers
vdos.writeVarUInt64(0x400000000L);
vdos.writeVarUInt64(0x800000000L);// 32-bit floats
vdos.writeFloat(0.75f);
vdos.writeFloat(Float.NaN);// 64-bit floats
vdos.writeDouble(1.25d);
vdos.writeDouble(Double.NaN);
```## Credit
- VarFloat/VarDouble format courtesy of [michaeljclark/vf128](https://github.com/michaeljclark/vf128)## License
```text
Copyright 2025 Wasabi CodesLicensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```