Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions 07-java-io/task03/src/com/example/task03/Task03Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,36 @@

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 {
//здесь вы можете вручную протестировать ваше решение, вызывая реализуемый метод и смотря результат
// например вот так:

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 {
public static String readAsString(InputStream inputStream, Charset charset) throws IOException
{
// your implementation here
return "";

if(inputStream == null || charset == null)
{
throw new IllegalArgumentException();
}
StringBuilder res = new StringBuilder();
InputStreamReader inStreamReader = new InputStreamReader(inputStream, charset);
while (inStreamReader.ready())
{
res.appendCodePoint(inStreamReader.read());
}

return res.toString();
}
}
}