質問編集履歴
3
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -38,7 +38,53 @@
|
|
38
38
|
}
|
39
39
|
}
|
40
40
|
```
|
41
|
+
```java
|
42
|
+
package main;
|
41
43
|
|
44
|
+
import java.io.File;
|
45
|
+
import java.io.IOException;
|
46
|
+
|
47
|
+
import com.drew.imaging.jpeg.JpegMetadataReader;
|
48
|
+
import com.drew.imaging.jpeg.JpegProcessingException;
|
49
|
+
import com.drew.metadata.exif.ExifDirectoryBase;
|
50
|
+
import com.drew.metadata.exif.ExifSubIFDDirectory;
|
51
|
+
|
52
|
+
public class ExifUtil {
|
53
|
+
|
54
|
+
public static String getPhotoDate(File pictureFile) {
|
55
|
+
ExifDirectoryBase directory = null;
|
56
|
+
String year;
|
57
|
+
String month;
|
58
|
+
String day;
|
59
|
+
String hour;
|
60
|
+
String minute;
|
61
|
+
String second;
|
62
|
+
try {
|
63
|
+
directory = JpegMetadataReader.readMetadata(pictureFile).getFirstDirectoryOfType(ExifDirectoryBase.class);
|
64
|
+
} catch (JpegProcessingException e) {
|
65
|
+
// TODO 自動生成された catch ブロック
|
66
|
+
e.printStackTrace();
|
67
|
+
} catch (IOException e) {
|
68
|
+
// TODO 自動生成された catch ブロック
|
69
|
+
e.printStackTrace();
|
70
|
+
}
|
71
|
+
|
72
|
+
year = directory.getString(ExifSubIFDDirectory.TAG_DATETIME).toString().substring(0, 4) + "年";
|
73
|
+
month = directory.getString(ExifSubIFDDirectory.TAG_DATETIME).toString().substring(5, 7) + "月";
|
74
|
+
day = directory.getString(ExifSubIFDDirectory.TAG_DATETIME).toString().substring(8, 10) + "日";
|
75
|
+
hour = directory.getString(ExifSubIFDDirectory.TAG_DATETIME).toString().substring(11, 13) + "時";
|
76
|
+
minute = directory.getString(ExifSubIFDDirectory.TAG_DATETIME).toString().substring(14, 16) + "分";
|
77
|
+
second = directory.getString(ExifSubIFDDirectory.TAG_DATETIME).toString().substring(17, 19) + "秒";
|
78
|
+
String pDate = year + month + day + hour + minute + second;
|
79
|
+
return pDate;
|
80
|
+
}
|
81
|
+
|
82
|
+
}
|
83
|
+
|
84
|
+
```
|
85
|
+
使用jar
|
86
|
+
xmpcore-5.1.2.jar
|
87
|
+
metadata-extractor-2.9.1.jar
|
42
88
|
上記のソースにフォルダごとに一意のファイル名を付けたいと思っています。
|
43
89
|
秒まで一致していると一意にならないため対策が必要なのですがどうやったらいいかがわかりません。
|
44
90
|
フォルダごとに番号を一意にしたいです。
|
2
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -40,5 +40,5 @@
|
|
40
40
|
```
|
41
41
|
|
42
42
|
上記のソースにフォルダごとに一意のファイル名を付けたいと思っています。
|
43
|
+
秒まで一致していると一意にならないため対策が必要なのですがどうやったらいいかがわかりません。
|
43
|
-
|
44
|
+
フォルダごとに番号を一意にしたいです。
|
44
|
-
どのようにしたら、一意のファイル名になりますか?
|
1
ファイルパス修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
public class Start {
|
7
7
|
|
8
8
|
public static void main(String[] args) {
|
9
|
-
String path = "
|
9
|
+
String path = "写真のあるディレクトリ";
|
10
10
|
mainProc(path);
|
11
11
|
|
12
12
|
}
|