-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSolution.java
More file actions
68 lines (41 loc) · 2.19 KB
/
Solution.java
File metadata and controls
68 lines (41 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//But these things have I told you, that when the time shall come, ye may remember that I told you of them.
//And these things I said not unto you at the beginning, because I was with you. (John 16:4)
package com.javarush.task.task31.task3103;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
/*
Своя реализация
*/
public class Solution {
public static byte[] readBytes(String fileName) throws IOException {
return Files.readAllBytes(Paths.get (fileName));
}
public static List<String> readLines(String fileName) throws IOException {
return Files.readAllLines(Paths.get(fileName));
}
public static void writeBytes(String fileName, byte[] bytes) throws IOException {
Files.write(Paths.get(fileName), bytes);
}
public static void copy(String resourceFileName, String destinationFileName) throws IOException {
Files.copy(Paths.get(resourceFileName), Paths.get(destinationFileName));
}
}
/*
Своя реализация
Реализуй логику методов:
1. readBytes - должен возвращать все байты файла fileName.
2. readLines - должен возвращать все строки файла fileName. Используй кодировку по умолчанию.
3. writeBytes - должен записывать массив bytes в файл fileName.
4. copy - должен копировать файл resourceFileName на место destinationFileName.
ГЛАВНОЕ УСЛОВИЕ:
Никаких других импортов!
Требования:
1. Импорты в классе Solution менять нельзя.
2. Метод readBytes должен возвращать все байты файла fileName.
3. Метод readLines должен возвращать все строки файла fileName с кодировкой по умолчанию.
4. Метод writeBytes должен записывать массив bytes в файл fileName.
5. Метод copy должен копировать файл resourceFileName на место destinationFileName.
*/