.
package en.codegym.task.pro.task15.task1530;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
/*
Bytes to characters
*/
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)));
}
//write your code here
public static char[] bytesToChars(ByteArrayInputStream stream, int n){
char[] charArr = new char[n];
byte[] bytes = stream.readAllBytes();
int remaining=bytes.length-n;
for(int i=0;i<bytes.length-remaining;i++){
charArr[i]=(char) bytes[i];
}
return charArr;
}
//10
//6
//4
}