Как правильно читать и преобразовывать содержимое текстового файла?
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]
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
public class Main {
  public static void main(String[] args) {
    File file = new File(args[0]);
    if (!file.exists()) {
      System.out.println(args[0] + " does not exist.");
      return;
    }
    if (!(file.isFile() && file.canRead())) {
      System.out.println(file.getName() + " cannot be read from.");
      return;
    }
    try {
      FileInputStream fis = new FileInputStream(file);
      char current;
      while (fis.available() > 0) {
        current = (char) fis.read();
        System.out.print(current);
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
}
//пример взят отсюда: ru.stackoverflow.com/questions/310036/%D0%A1%D1%87...