Class LanguageProfileReader
- java.lang.Object
-
- com.optimaize.langdetect.profiles.LanguageProfileReader
-
public class LanguageProfileReader extends Object
ReadsLanguageProfile
s.- Author:
- Fabian Kessler
-
-
Constructor Summary
Constructors Constructor Description LanguageProfileReader()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description LanguageProfile
read(File profileFile)
Reads aLanguageProfile
from a File in UTF-8.LanguageProfile
read(InputStream inputStream)
Reads aLanguageProfile
from an InputStream in UTF-8.List<LanguageProfile>
read(ClassLoader classLoader, String profileDirectory, Collection<String> profileFileNames)
Load profiles from the classpath in a specific directory.List<LanguageProfile>
read(String profileDirectory, Collection<String> profileFileNames)
Same asread(ClassLoader, String, java.util.Collection)
using the class loader of this class.List<LanguageProfile>
read(Collection<String> profileFileNames)
Same asread(ClassLoader, String, java.util.Collection)
using the class loader of this class, and the default profiles directory of this library.List<LanguageProfile>
readAll()
Deprecated.renamed to readAllBuiltIn()List<LanguageProfile>
readAll(File path)
Loads all profiles from the specified directory.List<LanguageProfile>
readAllBuiltIn()
Reads all built-in language profiles from the "languages" folder (shipped with the jar).@NotNull LanguageProfile
readBuiltIn(@NotNull LdLocale locale)
@NotNull List<LanguageProfile>
readBuiltIn(@NotNull Collection<LdLocale> languages)
-
-
-
Method Detail
-
read
public LanguageProfile read(File profileFile) throws IOException
Reads aLanguageProfile
from a File in UTF-8.- Throws:
IOException
-
read
public LanguageProfile read(InputStream inputStream) throws IOException
Reads aLanguageProfile
from an InputStream in UTF-8.- Throws:
IOException
-
read
public List<LanguageProfile> read(ClassLoader classLoader, String profileDirectory, Collection<String> profileFileNames) throws IOException
Load profiles from the classpath in a specific directory.This is usually used to load built-in profiles, shipped with the jar.
- Parameters:
classLoader
- the ClassLoader to load the profiles from. UseMyClass.class.getClassLoader()
profileDirectory
- profile directory path inside the classpath. The default profiles are in "languages".profileFileNames
- for example ["en", "fr", "de"].- Throws:
IOException
-
read
public List<LanguageProfile> read(String profileDirectory, Collection<String> profileFileNames) throws IOException
Same asread(ClassLoader, String, java.util.Collection)
using the class loader of this class.- Throws:
IOException
-
read
public List<LanguageProfile> read(Collection<String> profileFileNames) throws IOException
Same asread(ClassLoader, String, java.util.Collection)
using the class loader of this class, and the default profiles directory of this library.- Throws:
IOException
-
readBuiltIn
@NotNull public @NotNull LanguageProfile readBuiltIn(@NotNull @NotNull LdLocale locale) throws IOException
- Throws:
IOException
-
readBuiltIn
@NotNull public @NotNull List<LanguageProfile> readBuiltIn(@NotNull @NotNull Collection<LdLocale> languages) throws IOException
- Throws:
IOException
-
readAll
public List<LanguageProfile> readAll() throws IOException
Deprecated.renamed to readAllBuiltIn()- Throws:
IOException
-
readAllBuiltIn
public List<LanguageProfile> readAllBuiltIn() throws IOException
Reads all built-in language profiles from the "languages" folder (shipped with the jar).- Throws:
IOException
-
readAll
public List<LanguageProfile> readAll(File path) throws IOException
Loads all profiles from the specified directory. Do not use this method for files distributed within a jar.- Parameters:
path
- profile directory path- Returns:
- empty if there is no language file in it.
- Throws:
IOException
-
-