https://github.com/cloudogu/spotter
Content-Type and language recognition library
https://github.com/cloudogu/spotter
content-type detection java language maven mime-type recognition tika
Last synced: 3 months ago
JSON representation
Content-Type and language recognition library
- Host: GitHub
- URL: https://github.com/cloudogu/spotter
- Owner: cloudogu
- License: mit
- Created: 2017-11-26T21:41:10.000Z (over 7 years ago)
- Default Branch: develop
- Last Pushed: 2023-08-24T20:27:27.000Z (almost 2 years ago)
- Last Synced: 2024-04-13T22:48:08.952Z (over 1 year ago)
- Topics: content-type, detection, java, language, maven, mime-type, recognition, tika
- Language: Java
- Homepage:
- Size: 246 KB
- Stars: 4
- Watchers: 11
- Forks: 2
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Spotter
[](https://travis-ci.org/sdorra/spotter)
[](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22spotter%22)
[](https://sonarcloud.io/dashboard?id=com.cloudogu.spotter%3Aspotter)
[](https://sonarcloud.io/dashboard?id=com.cloudogu.spotter%3Aspotter)Spotter is a library which is able to detect the content type of a file.
It is also able to detect the programming language of source files.
Spotter uses [Apache Tika](https://tika.apache.org/) for the content type recognition and uses the [language.yml](https://raw.githubusercontent.com/github/linguist/master/lib/linguist/languages.yml) from the [Linguist project](https://github.com/github/linguist).## Usage
Add the latest stable version of to the dependency management tool of your choice.
E.g. for maven:
```xml
com.cloudogu.spotter
spotter-core
x.y.z```
Use the latest version from maven central: [](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22spotter%22)
For versions before 4.0.0 use the following coordinates:
```xml
com.github.sdorra
spotter-core
x.y.z```
### Examples
Detect the content type and the programming language of a file:
```java
ContentType contentType = ContentTypes.detect("com/cloudogu/spotter/Language.java");
System.out.println("Content-Type: " + contentType);Optional language = contentType.getLanguage();
if (language.isPresent()) {
System.out.println("Language : " + language.get().getName());
}
```## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details