Прошу помощи и разбора кода)))
Заранее спасибо!
package com.javarush.task.pro.task15.task1530;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
/*
Байты в символы
*/
public class Solution {
public static void main(String[] args) throws Exception {
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, 40)));
}
//напишите тут ваш код
public static char[] bytesToChars(ByteArrayInputStream stream, int n) throws Exception {
byte[] bytes = stream.readNBytes(n);
String byteConvert = new String(bytes);
char[] chars = byteConvert.toCharArray();
return chars;
}
}