Skip to content
/ xar Public

A Java library for reading and writing eXtensible ARchiver files by sprylab technologies GmbH.

License

Notifications You must be signed in to change notification settings

sprylab/xar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

e7c5d1c · Aug 11, 2023

History

74 Commits
Dec 22, 2020
Dec 22, 2020
May 8, 2023
May 8, 2023
Aug 11, 2023
Apr 24, 2019
Apr 24, 2020
May 19, 2019
May 13, 2016
May 19, 2019
Dec 22, 2020
Dec 22, 2020
May 8, 2023

Repository files navigation

xar for Java

A Java library for reading and writing eXtensible ARchiver files by sprylab technologies GmbH.

Work-in-progress note

This is the public preview version. It works for us, but it still has some rough corners and thus lacks consistent code style, sufficient unit tests and complete documentation. Especially the writing support is still experimental.

Use with care! We work on a fully polished version 1.0.0 and will release it, when it's done.

Thanks for your patience!

Usage

Open a .xar file:

XarSource xar = new FileXarSource(new File("my-file.xar"));

Open a .xar file from URL (needs xar-http module):

XarSource xar = new HttpXarSource("https://example.com/files/my-file.xar");

Extract a .xar file:

xar.extractAll(new File("extract-directory"));

Get a list of all entries:

List<XarEntry> entries = xar.getEntries();

Get a specific entry:

XarEntry entry = xar.getEntry("directory/file.txt");

Stream, extract or get bytes of a entry:

InputStream inputStream = entry.getInputStream();
entry.extract(new File("extract-directory"));
byte[] bytes = entry.getBytes();

Create a .xar file from directory:

XarPacker xarPacker = new XarPacker(new File("my-file.xar"));
xarPacker.addDirectory(new File("directory"), false, null));
xarPacker.write();

Download

Download the latest JAR or grab via Maven:

<dependency>
  <groupId>com.sprylab.xar</groupId>
  <artifactId>xar</artifactId>
  <version>0.9.9</version>
</dependency>

or Gradle:

compile 'com.sprylab.xar:xar:0.9.9'

If you need to access files via HTTP, add the xar-http module as a dependency, too:

<dependency>
  <groupId>com.sprylab.xar</groupId>
  <artifactId>xar-http</artifactId>
  <version>0.9.9</version>
</dependency>

or Gradle:

compile 'com.sprylab.xar:xar-http:0.9.9'

There is also a CLI version, which mimics the behavior of the original C executable. Download the latest standalone-JAR (all dependencies included) for direct use at the command line.

License

Copyright 2013-2018 sprylab technologies GmbH

Licensed 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 at

   http://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.

Related projects

Original C source: http://code.google.com/p/xar/

Fork/clone by @mackyle: https://github.com/mackyle/xar

JavaScript port by @finnp: https://github.com/finnp/xar

About

A Java library for reading and writing eXtensible ARchiver files by sprylab technologies GmbH.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages