質問: fileReader.read()) != -1) { String X; String S; S=String.valueOf(data); for(int i=0;i<10;i++){ X=X+S; } List.add(X);
回答: ``` final String srcPath = "C:\\Users\\Desktop\\file1.txt"; final String destPath = "C:\\Users\\Desktop\\file2.txt"; Path path = Paths.get(srcPath); if (!path.toFile().exists()) { System.err.println("ファイルが見つかりません。"); System.exit(1); } String result = new String(Files.readAllBytes(path)).codePoints() .mapToObj(i -> new String(new char[10]).replace('\0', (char) i)) .collect(Collectors.joining()); Files.write(Paths.get(destPath), result.getBytes()); ```