All pastes #271897 Raw Edit

lol hi

public java v1 · immutable
·published 2006-12-08 15:15 UTC
rendered paste body
// Jim Herreroimport java.io.*;import java.util.*;public class book{  public static boolean isAlpha() throws IOException  {    Scanner s = new Scanner(new File("bookindex.dat"));    //Scanner s = new Scanner(new File("bookindexfixed.txt"));    Stack<String> stacker = new Stack();    String thisline, lastline;    int thisindent, lastindent;    while(s.hasNextLine())    {      thisline = s.nextLine();      if(!thisline.trim().equals("")) // ignore empty lines      {        thisindent = getIndent(thisline);        if(stacker.empty())          stacker.push(thisline);        else        {          lastline = stacker.peek();          lastindent = getIndent(lastline);          if (thisindent == lastindent)          {            if (thisline.compareToIgnoreCase(lastline) < 0)            {              // If not alphabetical, print line that is out of order              System.out.println("last = " + lastline + ", " + lastindent +                               "\nthis = " + thisline + ", " + thisindent);              return false;            }            stacker.push(thisline);          }          if (thisindent > lastindent)            stacker.push(thisline);          while (thisindent < lastindent && !stacker.empty())            stacker.pop();        }      }    }    return true;  }  public static int getIndent(String str)  {    int indent = 0;    while(str.charAt(0) == ' ')    {      str = str.substring(1);      indent++;    }    return indent;  }}