[英]How to takes a filename from the command line & outputs that file heap sorted?
I'm new to java and would appreciate it if someone could give me some help. 我是Java的新手,如果有人可以给我一些帮助,我将不胜感激。 Thanks in advance.
提前致谢。
I am trying to take a filename from the command line and output that file sorted (from my Heap.java) and print it out one word per line. 我正在尝试从命令行获取文件名,并输出排序后的文件(来自我的Heap.java),然后每行将其打印出一个单词。
Here is what I have: 这是我所拥有的:
public class HeapSort {
public static void main(String[] args) throws IOException {
//public static void main(String[] args) {
// Declare and instantiate a new ArrayList object
ArrayList<String> data = new ArrayList<String>();
//Declare the input file names
String inFile = "data2415.txt";
Scanner sc = new Scanner(new File(args[0]));
if (0 < args.length){
String filename = args[0];
File file = new File(filename);
}
//h = reader.readLine();
while (sc.hasNext()) data.add(sc.next());
}
}
What about 关于什么
List<String> resultList = FileUtils.readlines("text.txt");
Collections.sort(resultList);
for (String s: resultList)
System.out.println(s);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.