Class pmr.util.StringList
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class pmr.util.StringList

java.lang.Object
   |
   +----pmr.util.StringList

public class StringList
extends Object
a simple storage for Strings (e.g. from input file); There are an arbitrary number of elements, each a String. A file can be read into a StringList and then successive lines can be extracted. There is doubtless a better way using Java :-( probably will become obsolete ...
Author:
(C) P. Murray-Rust, 1996

Constructor Index

 o StringList()
 o StringList(int)
 o StringList(String)
from whitespace-separated strings (" ", "\n", "\t")
 o StringList(String, String)
from delimiter-separated strings (delimiter(s) are lost)
 o StringList(String[])
from an array of Strings; *COPIED*

Method Index

 o add(String)
 o addElement(String)
synonymous with above
 o append(String[])
append an array of Strings
 o append(StringList)
add another StringList; by REFERENCE
 o contract()
return unused buffer space
 o debug()
 o elementAt(int)
synonymous with above
 o getCurrentLine()
read the current line and advance pointer by one line
 o getItem(int)
 o getLineNumber()
return the line pointer
 o getStrings()
return the list as an array of Strings
 o getStrings(String)
make an array of Strings out of space-separated tokens in 's'
 o outputToFile(File)
output to a file (lines are separated by \n)
 o outputToFile(String)
output to a file (lines are separated by \n)
 o peekLine()
read the current line but do not advance pointer
 o prepend(String[])
prepend an array of Strings
 o print()
 o readFile(String)
from a filename (local)
 o readURL(String)
from a URL (e.g.
 o readURL(URL)
alternative to the above
 o resetGet()
reset to start of file
 o setLastLineToNull()
set the last line to null (useful when memory is short).
 o setLineNumber(int)
sets the pointer to a given line number (no action if outside range)
 o size()
 o toString()
output as list of Strings, separated by \n (best we can do fo a simple application

Constructors

 o StringList
  public StringList()
 o StringList
  public StringList(String s[])
from an array of Strings; *COPIED*
 o StringList
  public StringList(int nbuff)
 o StringList
  public StringList(String s,
                    String delim)
from delimiter-separated strings (delimiter(s) are lost)
Parameters:
delim - has the same form as StringTokenizer
 o StringList
  public StringList(String s)
from whitespace-separated strings (" ", "\n", "\t")

Methods

 o readFile
  public static StringList readFile(String filename) throws FileNotFoundException, IOException
from a filename (local)
 o readURL
  public static StringList readURL(String urlname) throws MalformedURLException, IOException
from a URL (e.g. in an applet)
 o readURL
  public static StringList readURL(URL url) throws IOException
alternative to the above
 o contract
  public void contract()
return unused buffer space
 o size
  public int size()
 o getStrings
  public String[] getStrings()
return the list as an array of Strings
 o getStrings
  public static String[] getStrings(String s)
make an array of Strings out of space-separated tokens in 's'
 o getItem
  public String getItem(int i)
 o elementAt
  public String elementAt(int i)
synonymous with above
 o add
  public void add(String a)
 o addElement
  public void addElement(String s)
synonymous with above
 o append
  public void append(StringList s)
add another StringList; by REFERENCE
 o prepend
  public void prepend(String s[])
prepend an array of Strings
 o append
  public void append(String strings[])
append an array of Strings
 o getLineNumber
  public int getLineNumber()
return the line pointer
 o setLineNumber
  public void setLineNumber(int i)
sets the pointer to a given line number (no action if outside range)
 o setLastLineToNull
  public void setLastLineToNull()
set the last line to null (useful when memory is short). Does not delete the line pointer or alter line numbers; of course the StringList cannot then be rewound and re-read
 o resetGet
  public void resetGet()
reset to start of file
 o getCurrentLine
  public String getCurrentLine()
read the current line and advance pointer by one line
 o peekLine
  public String peekLine()
read the current line but do not advance pointer
 o print
  public void print()
 o outputToFile
  public void outputToFile(File f) throws IOException
output to a file (lines are separated by \n)
Throws: IOException
an output error occured
 o outputToFile
  public void outputToFile(String s) throws IOException
output to a file (lines are separated by \n)
Throws: IOException
an output error occured
 o toString
  public String toString()
output as list of Strings, separated by \n (best we can do fo a simple application
Overrides:
toString in class Object
 o debug
  public void debug()

All Packages  Class Hierarchy  This Package  Previous  Next  Index