/* Main - prototype java indexing machine by J. Doug Ohmans Copyright (C) 2015 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. */ import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws IOException { System.out.println(); System.out.println("test."); System.out.println("A Java Indexing Machine"); System.out.println("99 the Rain in Spain falls mainly on the Plain"); System.out.println("==>"); System.out.println("99 the Rain in Spain falls mainly on the Plain"); System.out.println("Indexing Machine | A Java"); System.out.println("Java Indexing Machine | A"); System.out.println("Machine | A Java Indexing"); System.out.println("Plain | 99 the Rain in Spain falls mainly on the"); System.out.println("Rain in Spain falls mainly on the Plain | 99 the"); System.out.println("Spain falls mainly on the Plain | 99 the Rain in"); System.out.println("test."); File binTemp = new File("binOutput.txt"); if (!binTemp.exists()) { binTemp.createNewFile(); } File binTmpo = new File("binObject.txt"); if (!binTmpo.exists()) { binTmpo.createNewFile(); } binList.main(null); binParse.main(null); Scanner sorter = new Scanner(new File("binOutput.txt")); ArrayList binSorted = new ArrayList(); String str; while (sorter.hasNextLine()) { str = sorter.nextLine(); binSorted.add(str); } Collections.sort(binSorted, new Comparator() { @Override public int compare(String s1, String s2) { return s1.compareToIgnoreCase(s2); } }); PrintWriter writer = new PrintWriter("binSorted.txt"); for (int i = 0; i < binSorted.size(); i++) { System.out.println(binSorted.get(i)); } System.out.println(); for (String Str: binSorted) { writer.write(Str + "\n"); } writer.close(); sorter.close(); binTemp.delete(); } }