I need help with using the Stringtokenizer. I'm not sure if it should be in a class, and called in the main. Or should be in my main program. this is the description : Using StringTokenizer, the program will parse the input file and identify words and integers. Words are notcase sensitive and can only contain letters, apostrophes, hyphens, and digits but must start with a letter. The numbers are a sequence of digits. They can be positive or negative integers. If the number is negative, there is no space between the negative sign, -, and the first digit. A sum will be made form the integers contained in the input file. StringTokenizer methods inline now contains the tokens. A few useful method of the StringTokenizer are: Boolean hasMoreTokens() // test if there are more tokens available from this tokenizer's string. String nextToken() // returns the next token from this string tokenizer. Int countTokens() //calculates the number of times that this tokenizer's nextToken method can be called before it generates an exception code in the main : class main { public static void main(String[] args) throws IOException { IOFile myFilesObj = new IOFile(); int i = 0; // Array index int count = 0; // number of Word objects in words array int sum = 0; // sum of integers // Word[] words = new Word[100]; // Array of word objects StringTokenizer inline; // Stringtokenizer of current line BufferedReader infile; // input file handle PrintWriter outfile; // output file handle myFilesObj.validateNames(args); infile = myFilesObj.openIn(myFilesObj.inputFileName); outfile = myFilesObj.openOut(myFilesObj.outputFileName); } }
I need help with using the Stringtokenizer. I'm not sure if it should be in a class, and called in the main. Or should be in my main
this is the description :
Using StringTokenizer, the program will parse the input file and identify words and integers. Words are notcase sensitive and can only contain letters, apostrophes, hyphens, and digits but must start with a letter. The numbers are a sequence of digits. They can be positive or negative integers. If the number is negative, there is no space between the negative sign, -, and the first digit. A sum will be made form the integers contained in the input file.
StringTokenizer methods
- inline now contains the tokens.
- A few useful method of the StringTokenizer are:
- Boolean hasMoreTokens() // test if there are more tokens available from this tokenizer's string.
- String nextToken() // returns the next token from this string tokenizer.
- Int countTokens() //calculates the number of times that this tokenizer's nextToken method can be called before it generates an exception
code in the main :
class main {
public static void main(String[] args) throws IOException {
IOFile myFilesObj = new IOFile();
int i = 0; // Array index
int count = 0; // number of Word objects in words array
int sum = 0; // sum of integers
// Word[] words = new Word[100]; // Array of word objects
StringTokenizer inline; // Stringtokenizer of current line
BufferedReader infile; // input file handle
PrintWriter outfile; // output file handle
myFilesObj.validateNames(args);
infile = myFilesObj.openIn(myFilesObj.inputFileName);
outfile = myFilesObj.openOut(myFilesObj.outputFileName);
}
}

Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images









