Skip to content

tchudyk/filetype-textbundle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TextBundle file type

This is Java implementation of TextBundle file type.

More information about this format you can find on official website textbundle.org

License: BSD.

Maven

Add repository to your pom.xml:

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

Add dependency:

<dependency>
    <groupId>com.github.tchudyk</groupId>
    <artifactId>filetype-textbundle</artifactId>
    <version>1.1.3</version>
</dependency>

Usage

Create TextBundle directory.

try (TextBundleDir dir = new TextBundleDir(Paths.get("myDir"))) {
    dir.writeContent(new TextContent(ContentType.MARKDOWN, "Sample Markdown file"));
    dir.writeAsset(new Asset("test1.txt", "raw-content".getBytes(StandardCharsets.UTF_8)));
    dir.writeAsset(new Asset("test2.txt", "raw-content2".getBytes(StandardCharsets.UTF_8)));
} catch (IOException e) {
    e.printStackTrace();
}

Create TextPack directory.

try (TextPack file = new TextPack(Paths.get("sample.textpack"))) {
    file.writeContent(new TextContent(ContentType.MARKDOWN, "Sample Markdown file"));
    file.writeAsset(new Asset("test1.txt", "raw-content".getBytes(StandardCharsets.UTF_8)));
    file.writeAsset(new Asset("test2.txt", "raw-content2".getBytes(StandardCharsets.UTF_8)));
} catch (IOException e) {
    e.printStackTrace();
}

Convert TextPack to TextBundle (unpack)

try (TextPack file = new TextPack(Paths.get("sample.textpack"))) {
    file.unpackTo(tempDir.resolve(Paths.get("/tmp/sample-unpacked")));
} catch (IOException e) {
    e.printStackTrace();
}

Convert TextBundle to TextPack (pack)

Path textPack = tempDir.resolve("sample.textpack");
try (TextBundleDir dir = new TextBundleDir(path)) {
    dir.packTo(textPack);
} catch (IOException e) {
    e.printStackTrace();
}

About

Java 1.8 implementation of TextBundle file type.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors 2

  •  
  •  

Languages