public static void main(String[] args) {
System.err.print(Arrays.toString(test()));
}
private static char[] test(){
StringBuilder sb = new StringBuilder();
try( BufferedReader br = new BufferedReader(new FileReader("D:\\text.txt"))) {
String str;
while( (str = br.readLine()) != null){
sb.append(str);
}
} catch (IOException ex) {
System.out.println(ex.getMessage());
return sb.toString().toCharArray();
}
return sb.toString().toCharArray();
}
}
Вывод:
run:
[a, s, d, a, s, f, g, a, s, f, d, a, s, d, s, d, g, s, d, g, a, d, f, h, b, s, a, b, w, 4, q, g, , g, 3, , t, , 3, g, , 3, g, 3, g, , , g, r, v, 3]