/** * 扫描单个目录 * * @throws Exception */ private void runSim() throws Exception { picMetaInfoDao = new PicMetaInfoDao(); picMetaInfoDao.init(); String filePath = "E:\\360_sync\\Sync\\Photos\\wallpaper"; File picDir = new File(filePath); picInfoReader.runOneDirectory(picDir); // close picMetaInfoDao.close(); }
/** * 将一个文件转化为 PicMetaInfo 对象 * * @param file * @return */ public PicMetaInfo toPicMetaInfo(File file) { PicMetaInfo picMetaInfo = null; try { Metadata metadata = ImageMetadataReader.readMetadata(file); picMetaInfo = picInfoReader.toPicMetaInfo(metadata, file); return picMetaInfo; } catch (Exception e) { e.printStackTrace(); return null; } }