jpayne@68: package fileIO; jpayne@68: import java.io.BufferedReader; jpayne@68: import java.io.File; jpayne@68: import java.io.InputStream; jpayne@68: import java.io.InputStreamReader; jpayne@68: import java.util.ArrayList; jpayne@68: jpayne@68: import shared.Shared; jpayne@68: import shared.Timer; jpayne@68: import shared.Tools; jpayne@68: jpayne@68: jpayne@68: public class TextFile { jpayne@68: jpayne@68: jpayne@68: public static void main(String[] args){ jpayne@68: TextFile tf=new TextFile(args.length>0 ? args[0] : "stdin", false); jpayne@68: int first=0; jpayne@68: long last=100; jpayne@68: boolean speedtest=false; jpayne@68: if(args.length>1){ jpayne@68: if(args[1].equalsIgnoreCase("speedtest")){ jpayne@68: speedtest=true; jpayne@68: first=0; jpayne@68: last=Long.MAX_VALUE; jpayne@68: }else{ jpayne@68: first=Integer.parseInt(args[1]); jpayne@68: last=first+100; jpayne@68: } jpayne@68: } jpayne@68: if(args.length>2){ jpayne@68: last=Integer.parseInt(args[2]); jpayne@68: } jpayne@68: speedtest(tf, first, last, !speedtest); jpayne@68: jpayne@68: // long lines=0; jpayne@68: // long bytes=0; jpayne@68: // if(args.length>1){ jpayne@68: // first=Integer.parseInt(args[1]); jpayne@68: // last=first+100; jpayne@68: // } jpayne@68: // if(args.length>2){ jpayne@68: // last=Integer.parseInt(args[2]); jpayne@68: // } jpayne@68: // jpayne@68: // for(int i=0; i list=new ArrayList(4096); jpayne@68: jpayne@68: for(s=nextLine(); s!=null; s=nextLine()){ jpayne@68: list.add(s); jpayne@68: } jpayne@68: jpayne@68: return list.toArray(new String[list.size()]); jpayne@68: jpayne@68: } jpayne@68: jpayne@68: public final long countLines(){ jpayne@68: jpayne@68: String s=null; jpayne@68: long count=0; jpayne@68: jpayne@68: for(s=nextLine(); s!=null; s=nextLine()){count++;} jpayne@68: jpayne@68: reset(); jpayne@68: jpayne@68: return count; jpayne@68: jpayne@68: } jpayne@68: jpayne@68: public static String[][] doublesplitTab(String[] lines, boolean trim){ jpayne@68: String[][] lines2=new String[lines.length][]; jpayne@68: for(int i=0; i