Examples-GroupDocs.Metadata-for-Java
// Gets directory name and recognizes format of files in that directory
public static void getFileFormats(String directorPath)
{
try
{
// path to the document
directorPath = Common.mapSourceFilePath(directorPath);
File dir = new File(directorPath);
// get array of files in specific directory
File[] files = dir.listFiles();
for (File path : files)
{
// recognize file by it's signature
FormatBase format = FormatFactory.recognizeFormat(path.getAbsolutePath());
if (format != null)
{
System.out.printf("File: %s, type: %s", path.getName(), format.getType());
}
}
}
catch (Exception e)
{
e.printStackTrace();
}
}