-
Notifications
You must be signed in to change notification settings - Fork 206
Expand file tree
/
Copy pathTask03Main.java
More file actions
25 lines (21 loc) · 1.01 KB
/
Task03Main.java
File metadata and controls
25 lines (21 loc) · 1.01 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
package com.example.task03;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
public class Task03Main {
public static void main(String[] args) throws IOException {
//здесь вы можете вручную протестировать ваше решение, вызывая реализуемый метод и смотря результат
// например вот так:
/*
System.out.println(readAsString(new FileInputStream("task03/src/com/example/task03/input.test"), Charset.forName("KOI8-R")));
*/
}
public static String readAsString(InputStream inputStream, Charset charset) throws IOException {
// your implementation here
if (inputStream != null && Charset.isSupported(charset.toString()))
return new BufferedReader(new InputStreamReader(inputStream, charset)).readLine();
throw new IllegalArgumentException();
}
}