source: josm/trunk/src/com/drew/metadata/file/FileMetadataReader.java@ 8243

Last change on this file since 8243 was 8243, checked in by Don-vip, 10 years ago

fix #11359 - update to metadata-extractor 2.8.1

File size: 975 bytes
Line 
1package com.drew.metadata.file;
2
3import com.drew.lang.annotations.NotNull;
4import com.drew.metadata.Metadata;
5
6import java.io.File;
7import java.io.IOException;
8import java.util.Date;
9
10public class FileMetadataReader
11{
12 public void read(@NotNull File file, @NotNull Metadata metadata) throws IOException
13 {
14 if (!file.isFile())
15 throw new IOException("File object must reference a file");
16 if (!file.exists())
17 throw new IOException("File does not exist");
18 if (!file.canRead())
19 throw new IOException("File is not readable");
20
21 FileMetadataDirectory directory = new FileMetadataDirectory();
22
23 directory.setString(FileMetadataDirectory.TAG_FILE_NAME, file.getName());
24 directory.setLong(FileMetadataDirectory.TAG_FILE_SIZE, file.length());
25 directory.setDate(FileMetadataDirectory.TAG_FILE_MODIFIED_DATE, new Date(file.lastModified()));
26
27 metadata.addDirectory(directory);
28 }
29}
Note: See TracBrowser for help on using the repository browser.