Всем привет, подскажите, пожалуйста, вроде вывод верный, что не так?
package com.javarush.task.pro.task15.task1530;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
/*
Байты в символы
*/
public class Solution {
public static void main(String[] args) {
ByteArrayInputStream stream = new ByteArrayInputStream("O sole, o sole mio!\nSta 'nfronte a te!\n Sta 'nfronte a te!".getBytes(StandardCharsets.UTF_8));
System.out.println(new String(bytesToChars(stream, 38)));
}
public static char[] bytesToChars(ByteArrayInputStream stream, int n) {
ArrayList<Character> list = new ArrayList<>();
while (stream.available() != 0) {
for (int i = 0; i <= n; i++) {
list.add((char)stream.read());
}
break;
}
int length = list.size();
char[] array = new char[length];
for(int i = 0; i < length; i++) {
array[i] = list.get(i);
}
return array;
}
//напишите тут ваш код
}