MimeType Resolver

This library resolves a mime-type of file by the binary content.

License

License

Categories

Categories

Ant Build Tools
GroupId

GroupId

com.antkorwin
ArtifactId

ArtifactId

mimetype
Last Version

Last Version

0.2
Release Date

Release Date

Type

Type

jar
Description

Description

MimeType Resolver
This library resolves a mime-type of file by the binary content.
Project URL

Project URL

https://github.com/antkorwin/mimetype
Source Code Management

Source Code Management

http://github.com/antkorwin/mimetype

Download mimetype

How to add to project

<!-- https://jarcasting.com/artifacts/com.antkorwin/mimetype/ -->
<dependency>
    <groupId>com.antkorwin</groupId>
    <artifactId>mimetype</artifactId>
    <version>0.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.antkorwin/mimetype/
implementation 'com.antkorwin:mimetype:0.2'
// https://jarcasting.com/artifacts/com.antkorwin/mimetype/
implementation ("com.antkorwin:mimetype:0.2")
'com.antkorwin:mimetype:jar:0.2'
<dependency org="com.antkorwin" name="mimetype" rev="0.2">
  <artifact name="mimetype" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.antkorwin', module='mimetype', version='0.2')
)
libraryDependencies += "com.antkorwin" % "mimetype" % "0.2"
[com.antkorwin/mimetype "0.2"]

Dependencies

compile (4)

Group / Artifact Type Version
com.antkorwin : throwable-functions jar 1.2
org.apache.tika : tika-core jar 1.24.1
org.apache.tika : tika-parsers jar 1.24.1
commons-codec : commons-codec jar 1.14

test (7)

Group / Artifact Type Version
com.antkorwin : ioutils jar 0.3
org.assertj : assertj-core jar 3.9.1
org.mockito : mockito-core jar 2.15.0
org.hamcrest : hamcrest-core jar 1.3
org.hamcrest : hamcrest-library jar 1.3
org.junit.jupiter : junit-jupiter-api jar 5.6.2
org.junit.jupiter : junit-jupiter-engine jar 5.6.2

Project Modules

There are no modules declared in this project.

Get MimeType of the file in Java

Build Status

This is a collection of simple classes which retrieve meta-data from the file content.

1. Getting started

Just add the following dependency in your pom.xml file:

<dependency>
    <groupId>com.antkorwin</groupId>
    <artifactId>mimetype</artifactId>
    <version>0.1</version>
</dependency>

2. How to get mime-type of file in java

File file = new File("document.pdf");
String type = new MimeTypeResolver().get(file);
System.out.println(type);

this code prints : application/pdf

3. How to get SHA-256 of file content in Java

File file = new File("document.pdf");
String sha256 = new Sha256Resolver().get(file);
System.out.println(sha256);

this code prints the SHA-256 of the document.pdf file : bbf9546ec49f2bfe384a91cb5a33831c67a69fb8a7197346f261df0aa8f7a048

4. How to extract text of the Word\Excel\Pdf document in Java

File file = new ResourceFile("word.docx").getFile();
String text = new FileTextResolver().get(file);
assertThat(text).containsSubsequence("This is the content of word file...");

Versions

Version
0.2
0.1