0

为什么NoSuchFileException在说明设置为 Eclipse 的正确路径时会出错?

例外

这是用于测试和失败的类 Part1:

public class Part1 {
    private static String input = Part1
            .readFile("C:\\Users\\Влад\\eclipse-workspace\\Practice3\\src\\ua\\nure\\budiakov\\practice3\\part1.txt");
    private static final String ENCODING = "UTF-8";

    public static String readFile(String path) {
        String res = null;
        try {
            byte[] bytes = Files.readAllBytes(Paths.get(path));
            res = new String(bytes, ENCODING);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        return res;
    }

    public static String convert1(String input) {
        String[] text = input.split(System.lineSeparator());
        StringBuilder sb = new StringBuilder();
        for (int i = 1; i < text.length; i++) {
            String[] a = text[i].split(";");
            sb.append(a[0] + ": " + a[a.length - 1] + System.lineSeparator());
        }
        return sb.toString();
    }

    public static void main(String[] args) throws IOException {
        System.out.println(Part1.convert1(input) + System.lineSeparator());
    }

}
4

0 回答 0