【发布时间】:2016-06-28 22:46:53
【问题描述】:
我是 java 新手,如果有人能给我一些帮助,我将不胜感激。提前致谢。
我正在尝试从命令行获取文件名并输出排序后的文件(从我的 Heap.java 中),然后每行打印一个单词。
这是我所拥有的:
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());
}
}
【问题讨论】:
标签: java command-line heap command-line-arguments heapsort