Skip to content

breadcat-dev/toolbox

Repository files navigation

Toolbox

License: MIT Java Status Release

Lightweight utility library for Java projects

Part of the TANK Series.


Features

  • File utilities (copy, move, traversal, path helpers)
  • Binary utilities (bit manipulation)
  • String utilities
  • ANSI color constants
  • Data and time unit constants
  • Lightweight with no external dependencies

Design Goals

  • Clean API
  • Minimal
  • Lightweight

Installation

Currently, Toolbox 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/toolbox.git
cd toolbox

Linux / MacOS

./gradlew publishToMavenLocal

Windows

./gradlew.bat publishToMavenLocal

Once installed, add the dependency:

Groovy

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

Kotlin DSL

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

Examples

AnsiUtil

System.out.println(AnsiUtil.RED + "This text is red." + AnsiUtil.RESET);

BinaryUtil

long byteTest = 0; // 00000000 00000000 00000000 00000000
byteTest = BinaryUtil.setBit(byteTest, 2); // 00000000 00000000 00000000 00000100

FileIOUtil

Path useful = Path.of("./input.bin");
Path backupUseful = Path.of("./backup/input.bin");

try
{
    FileIOUtil.copy(useful, backupUseful);
}
catch(IOException e)
{
    throw new RuntimeException(e);    
}

FileQueryUtil

Path chosenDirectory = Path.of("./project");
List<Path> filesInDirectory = new ArrayList<>();
try
{
    filesInDirectory = FileQueryUtil.files(chosenDirectory);
}
catch(IOException e)
{
    throw new RuntimeException(e);    
}

( File structure )

project/
├── test.txt
├── main.c
└── assets/
    ├── icon.png
    └── breadcat.png

( filesInDirectory )

./project/test.txt
./project/main.c
./project/assets/icon.png
./project/assets/breadcat.png

PathUtil

Path file = Path.of("./Main.java");
String extension = PathUtil.extension(file);

( extension )

String extension = "java";

StringUtil

String text = StringUtil.join(", ", "breadcat", 43, true);
System.out.println(text);

breadcat, 43, true

BinaryDataUnits

System.out.println("There are " + BinaryDataUnits.MiB + " bytes in a MiB.");

There are 1048576 bytes in a MiB.


Dependencies:

This library has no external dependencies.

About

Lightweight utility library for Java projects

Topics

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages