Funkcja do wykorzystania w zadaniu drugim
static String readFile(String name, Charset charset){ StringBuilder s = new StringBuilder(); try( BufferedReader file = new BufferedReader(new InputStreamReader( new FileInputStream(name), charset))){ for(;;){ int c=file.read(); if(c<0)break; s.append((char)c); } return s.toString(); } catch (IOException ex) { ex.printStackTrace(); } return ""; }