Skip to content

Commit

Permalink
Added BinaryTools implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Perfilyev committed Aug 21, 2023
1 parent 209a14a commit f53bb8c
Show file tree
Hide file tree
Showing 27 changed files with 3,002 additions and 20 deletions.
57 changes: 38 additions & 19 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,43 @@
# Compiled class file
*.class
.idea
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

# Log file
*.log
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

# BlueJ files
*.ctxt
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

# Mobile Tools for Java (J2ME)
.mtj.tmp/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
### VS Code ###
.vscode/

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*
### Mac OS ###
.DS_Store
80 changes: 79 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,79 @@
# BinaryJson
# BinaryTools Java Library

BinaryTools is a Java library designed to simplify reading and writing binary data from various sources, offering support for both Little Endian and Big Endian formats. It provides two main components: `BinaryReader` and `BinaryWriter`, which enable users to seamlessly handle binary data in their applications.

## Features

- Read primitive types (e.g., integers, floating-point numbers) from binary sources.
- Read strings from binary sources, supporting various character encodings.
- Specify either Little Endian or Big Endian byte order for reading data.
- Write primitive types and strings to binary output streams.
- Flexible and easy-to-use API for interacting with binary data.

## Installation

You can include BinaryTools in your project using Maven or Gradle. Add the following dependency to your project configuration:

```xml
<dependency>
<groupId>local.tools</groupId>
<artifactId>binarytools</artifactId>
<version>1.0.0</version>
</dependency>
```

## Usage

### BinaryReader

```java
import com.example.binarytools.BinaryReader;
import java.io.FileInputStream;
import java.io.IOException;

public class BinaryReaderExample {
public static void main(String[] args) throws IOException {
try (FileInputStream inputStream = new FileInputStream("data.bin")) {
BinaryReader reader = new BinaryReader(inputStream, EndianType.LittleEndian);

int intValue = reader.readInt();
double doubleValue = reader.readDouble();
String stringValue = reader.readString(10); // Read a string with maximum length 10

System.out.println("Read values: " + intValue + ", " + doubleValue + ", " + stringValue);
}
}
}
```

### BinaryWriter

```java
import com.example.binarytools.BinaryWriter;
import java.io.FileOutputStream;
import java.io.IOException;

public class BinaryWriterExample {
public static void main(String[] args) throws IOException {
try (FileOutputStream outputStream = new FileOutputStream("output.bin")) {
BinaryWriter writer = new BinaryWriter(outputStream, EndianType.LittleEndian);

writer.writeInt(42);
writer.writeDouble(3.14);
writer.writeString("Hello, BinaryTools!");
}
}
}
```

## License

This library is released under the [MIT License](LICENSE).

## Contributions

Contributions are welcome! Feel free to submit issues and pull requests on the [GitHub repository](https://github.com/aperfilev/binarytools).

## Contact

For questions, suggestions, or feedback, you can reach us at alexperfilev@gmail.com
19 changes: 19 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
plugins {
id 'java'
}

group = 'local.tools'
version = '1.0-SNAPSHOT'

repositories {
mavenCentral()
}

dependencies {
testImplementation platform('org.junit:junit-bom:5.9.1')
testImplementation 'org.junit.jupiter:junit-jupiter'
}

test {
useJUnitPlatform()
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Mon Aug 21 12:00:17 PDT 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit f53bb8c

Please sign in to comment.