Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/antkorwin/mimetype
https://github.com/antkorwin/mimetype
Last synced: 27 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/antkorwin/mimetype
- Owner: antkorwin
- Created: 2020-08-10T23:53:47.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-08-14T05:00:17.000Z (about 4 years ago)
- Last Synced: 2023-06-29T20:10:29.903Z (over 1 year ago)
- Language: Java
- Size: 68.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.adoc
Awesome Lists containing this project
README
:sectnums:
= Get MimeType of the file in Java
image:https://github.com/antkorwin/mimetype/workflows/Build/badge.svg["Build Status"]
This is a collection of simple classes which retrieve meta-data from the file content.
== Getting started
Just add the following dependency in your pom.xml file:
[source,xml]
----com.antkorwin
mimetype
0.1----
== How to get mime-type of file in java
[source,java]
----
File file = new File("document.pdf");
String type = new MimeTypeResolver().get(file);
System.out.println(type);
----this code prints : `application/pdf`
== How to get SHA-256 of file content in Java
[source,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`== How to extract text of the Word\Excel\Pdf document in Java
[source, java]
----
File file = new ResourceFile("word.docx").getFile();
String text = new FileTextResolver().get(file);
assertThat(text).containsSubsequence("This is the content of word file...");
----