Skip to content

Commit c4011b8

Browse files
author
Tanechka
committed
Lesson08 File and Resources
1 parent f4844c2 commit c4011b8

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package ru.javawebinar.basejava;
2+
3+
import java.io.File;
4+
import java.io.FileInputStream;
5+
import java.io.IOException;
6+
7+
/**
8+
* gkislin
9+
* 21.07.2016
10+
*/
11+
public class MainFile {
12+
public static void main(String[] args) {
13+
String filePath = ".\\.gitignore";
14+
15+
File file = new File(filePath);
16+
try {
17+
System.out.println(file.getCanonicalPath());
18+
} catch (IOException e) {
19+
throw new RuntimeException("Error", e);
20+
}
21+
22+
File dir = new File("./src/ru/javawebinar/basejava");
23+
System.out.println(dir.isDirectory());
24+
String[] list = dir.list();
25+
if (list != null) {
26+
for (String name : list) {
27+
System.out.println(name);
28+
}
29+
}
30+
31+
try (FileInputStream fis = new FileInputStream(filePath)) {
32+
System.out.println(fis.read());
33+
} catch (IOException e) {
34+
throw new RuntimeException(e);
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)