Skip to content

breadcat-dev/breech

Repository files navigation

Breech

License: MIT Java Status Release

A lightweight binary I/O library for Java projects

Part of the TANK Series.


Features

  • Read and write all Java primitive types
  • Big-endian and little-endian support
  • Variable-size bitfields (1–8 bytes)
  • UTF-8 string serialization
  • Sequential binary readers and writers
  • Small, straightforward API

Design Goals

  • Simple
  • Lightweight
  • Reusable

Installation

Currently, Breech is not on Maven Central. To use it, clone the repository and publish it to your local Maven Repository.

git clone https://github.com/breadcat-dev/breech.git
cd breech

Linux / MacOS

./gradlew publishToMavenLocal

Windows

./gradlew.bat publishToMavenLocal

Once installed, add the dependency:

Groovy

implementation "cat.breadcat:breech:<version>"

Kotlin DSL

implementation("cat.breadcat:breech:<version>")

Examples

Writing

try(BinaryWriter writer = new BinaryWriter
(
    new FileOutputStream("save.dat"),
    ByteOrder.LITTLE_ENDIAN
))
{
    writer.writeString("BreadCat");
    writer.writeInt(64);
    writer.writeFloat(3.14f);
}
catch(IOException e)
{
    throw new RuntimeException(e);
}

Reading

try(BinaryReader reader = new BinaryReader
(
    new FileInputStream("save.dat"),
    ByteOrder.LITTLE_ENDIAN
))
{
    String name = reader.readString();
    int coins = reader.readInt();
    int exp = reader.readFloat();
}
catch(IOException e)
{
    throw new RuntimeException(e);
}

Bitfield

try(BinaryWriter writer = new BinaryWriter
(
        new FileOutputStream("save.dat"),
        ByteOrder.LITTLE_ENDIAN
))
{
    Bitfield bitfield = new BitfieldBuilder(1)
            .bit(true)
            .bit(false)
            .bit(true)
            .build();
    
    writer.writeBitfield(bitfield);
}
catch(IOException e)
{
    throw new RuntimeException(e);
}

Dependencies:

About

Lightweight binary I/O library for Java projects

Topics

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages