class ex00 {
// あとで追加
System.
out.
print("ファイル名を入力してください:"); file f = new file(d);
System.
out.
println(f.
getAllData());
System.
out.
println("行数を入力してください"); int n
= Integer.
parseInt(br.
readLine()); System.
out.
println(f.
readLine(n
));
f.sort();
System.
out.
println(f.
getAllData()); }
}
class file {
int i = 0;
while (br.ready()) {
lines[i] = br.readLine();
i++;
}
}
public String readLine
(int n
) { return lines[n];
}
for (int i = 0; i < lines.length; i++) {
result += lines[i] + "\n";
}
return (result);
}
public void sort() {
Arrays.
sort(lines,
new Comparator
<String
>() { return Integer.
compare(o1.
length(), o2.
length()); }
});
}
}
Y2xhc3MgZXgwMCB7CiAgICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKSB0aHJvd3MgRXhjZXB0aW9uIHsKICAgICAgICAvLyDjgYLjgajjgafov73liqAKICAgICAgICBCdWZmZXJlZFJlYWRlciBiciA9IG5ldyBCdWZmZXJlZFJlYWRlcihuZXcgSW5wdXRTdHJlYW1SZWFkZXIoU3lzdGVtLmluKSk7CiAgICAgICAgU3lzdGVtLm91dC5wcmludCgi44OV44Kh44Kk44Or5ZCN44KS5YWl5Yqb44GX44Gm44GP44Gg44GV44GE77yaIik7CiAgICAgICAgU3RyaW5nIGQgPSBici5yZWFkTGluZSgpOwogICAgICAgIGZpbGUgZiA9IG5ldyBmaWxlKGQpOwogICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbihmLmdldEFsbERhdGEoKSk7CiAgICAgICAgCiAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCLooYzmlbDjgpLlhaXlipvjgZfjgabjgY/jgaDjgZXjgYQiKTsKICAgICAgICBpbnQgbiA9IEludGVnZXIucGFyc2VJbnQoYnIucmVhZExpbmUoKSk7CiAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKGYucmVhZExpbmUobikpOwogICAgICAgIAogICAgICAgIGYuc29ydCgpOwogICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbihmLmdldEFsbERhdGEoKSk7CiAgICB9Cn0KCmNsYXNzIGZpbGUgewogICAgU3RyaW5nIGZpbGVfbmFtZTsKICAgIFN0cmluZ1tdIGxpbmVzID0gbmV3IFN0cmluZ1sxMF07CgogICAgZmlsZShTdHJpbmcgX2ZpbGVuYW1lKSB0aHJvd3MgRXhjZXB0aW9uIHsKICAgICAgICBGaWxlSW5wdXRTdHJlYW0gZmlzID0gbmV3IEZpbGVJbnB1dFN0cmVhbShfZmlsZW5hbWUpOwogICAgICAgIElucHV0U3RyZWFtUmVhZGVyIGlzciA9IG5ldyBJbnB1dFN0cmVhbVJlYWRlcihmaXMpOwogICAgICAgIEJ1ZmZlcmVkUmVhZGVyIGJyID0gbmV3IEJ1ZmZlcmVkUmVhZGVyKGlzcik7CiAgICAgICAgaW50IGkgPSAwOwogICAgICAgIHdoaWxlIChici5yZWFkeSgpKSB7CiAgICAgICAgICAgIGxpbmVzW2ldID0gYnIucmVhZExpbmUoKTsKICAgICAgICAgICAgaSsrOwogICAgICAgIH0KICAgIH0KICAgIAogICAgcHVibGljIFN0cmluZyByZWFkTGluZShpbnQgbikgewogICAgICAgIHJldHVybiBsaW5lc1tuXTsKICAgIH0KCiAgICBwdWJsaWMgU3RyaW5nIGdldEFsbERhdGEoKSB7CiAgICAgICAgU3RyaW5nIHJlc3VsdCA9ICIiOwogICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbGluZXMubGVuZ3RoOyBpKyspIHsKICAgICAgICAgICAgcmVzdWx0ICs9IGxpbmVzW2ldICsgIlxuIjsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIChyZXN1bHQpOwogICAgfQogICAgCiAgICBwdWJsaWMgdm9pZCBzb3J0KCkgewogICAgICAgIEFycmF5cy5zb3J0KGxpbmVzLCBuZXcgQ29tcGFyYXRvcjxTdHJpbmc+KCkgewogICAgICAgICAgICBwdWJsaWMgaW50IGNvbXBhcmUoU3RyaW5nIG8xLCBTdHJpbmcgbzIpIHsKICAgICAgICAgICAgICAgIHJldHVybiBJbnRlZ2VyLmNvbXBhcmUobzEubGVuZ3RoKCksIG8yLmxlbmd0aCgpKTsKICAgICAgICAgICAgfQogICAgICAgIH0pOwogICAgfQp9Cg==