質問編集履歴

1

コード部分をMarkdown表記に直しました。

2019/06/10 06:31

投稿

junkjunk
junkjunk

スコア26

test CHANGED
File without changes
test CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
 
8
8
 
9
-
9
+ ```java
10
10
 
11
11
  public class b {
12
12
 
@@ -14,33 +14,33 @@
14
14
 
15
15
 
16
16
 
17
- // ファイルの最終更新日時(タイムスタンプ)を取得
17
+ // ファイルの最終更新日時(タイムスタンプ)を取得
18
18
 
19
- // 1970年1月1日0時0分0秒からの経過ミリ秒
19
+ // 1970年1月1日0時0分0秒からの経過ミリ秒
20
20
 
21
- long lastModified = source.lastModified();//sourceがコピー元のファイルです
21
+ long lastModified = source.lastModified();//sourceがコピー元のファイルです
22
22
 
23
23
 
24
24
 
25
- //最終更新日時表示書式
25
+ //最終更新日時表示書式
26
26
 
27
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
27
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
28
28
 
29
- //最終更新日時書式整形
29
+ //最終更新日時書式整形
30
30
 
31
- String lastModifiedStr = sdf.format(lastModified);
31
+ String lastModifiedStr = sdf.format(lastModified);
32
32
 
33
- System.out.println(lastModifiedStr);
33
+ System.out.println(lastModifiedStr);
34
34
 
35
35
 
36
36
 
37
- //ここら辺でエラー
37
+ //ここら辺でエラー
38
38
 
39
- //sourceファイルの更新日時を基に型変換を行いたいです
39
+ //sourceファイルの更新日時を基に型変換を行いたいです
40
40
 
41
- Calendar cal1 = Calendar.getInstance();
41
+ Calendar cal1 = Calendar.getInstance();
42
42
 
43
- cal1.getTime(source.lastModified());
43
+ cal1.getTime(source.lastModified());
44
44
 
45
45
 
46
46
 
@@ -62,26 +62,28 @@
62
62
 
63
63
  //ファイルのコピー
64
64
 
65
- Path sourcePath = Paths.get(cal1.getPath());
65
+ Path sourcePath = Paths.get(cal1.getPath());
66
66
 
67
- Path destinationPath = Paths.get("D:\test\sub\" + source.getName() + ".txt");
67
+ Path destinationPath = Paths.get("D:\test\sub\" + source.getName() + ".txt");
68
68
 
69
69
 
70
70
 
71
- try {
71
+ try {
72
72
 
73
- Files.copy(sourcePath,destinationPath);
73
+ Files.copy(sourcePath,destinationPath);
74
74
 
75
- } catch (IOException e) {
75
+ } catch (IOException e) {
76
76
 
77
- e.printStackTrace();
77
+ e.printStackTrace();
78
78
 
79
- }
79
+ }
80
80
 
81
- }
81
+ }
82
82
 
83
83
 
84
84
 
85
85
  }
86
86
 
87
87
  }
88
+
89
+ ```