/*************** clib Java Class by Charles Bloom some stdlib functions: atol,atoi strupr ***************/ import java.io.*; class clib { public static String[] stringSpaceTok(String in_str) { String str = new String(in_str); GrowingStringArray stringsOut = new GrowingStringArray(); int curI,nextI; str.replace('\t',' '); str.replace('\r',' '); str.replace('\n',' '); curI = 0; do { if ( (nextI = str.indexOf(' ',curI)) == -1 ) { stringsOut.append( str.substring(curI) ); break; } if ( str.charAt(curI) == '"' ) { curI++; if ( (nextI = str.indexOf('"',curI)) == -1 ) return(null); stringsOut.append( str.substring(curI,nextI) ); curI = nextI+2; } else { stringsOut.append( str.substring(curI,nextI) ); curI = nextI+1; } } while( curI < str.length() ); return( stringsOut.condensedA() ); }; public static boolean askContinue() { System.err.println("Continue? y/n"); try { for(;;) { switch( System.in.read() ) { case 'y': case 'Y': while ( System.in.read() != '\n' ) ; return(true); case 'n': case 'N': while ( System.in.read() != '\n' ) ; return(false); default: break; } } } catch ( IOException e ) { return(false); } }; public static int countFileLines(String fname) { FileInputStream fin; DataInputStream in; int ret; try { fin = new FileInputStream(fname); } catch ( IOException e ) { return(0); } in = new DataInputStream( fin ); ret=0; try { while ( in.readLine() != null ) ret++; } catch ( IOException e ) { } try { fin.close(); } catch ( IOException e ) { } return(ret); }; public static void writeFileLines(String fname,String[] strings) { FileOutputStream fout; int i,numlines = strings.length; PrintStream out; String[] ret; try { fout = new FileOutputStream(fname); } catch ( IOException e ) { return; } out = new PrintStream( fout ); for(i=0;i