text saying paultimney.com

Pepperpot > Example code

//Created by Paul Timney, April 2005

//Class to reset the values of index.txt back to NULL so it can be reused on each new search for a recipe

import java.awt.*;
import java.io.*;

public class ResetNulls
{

//global variables
public String name;
public double question;

public ResetNulls() throws IOException
{

//new file reader which take nulls.txt as the parameter
FileReader inputFile = new FileReader("\\My Documents\\recipes\\nulls.txt");

//new file writer that takes index.txt as the parameter
FileWriter output = new FileWriter("\\My Documents\\recipes\\index.txt");
PrintWriter outputFile = new PrintWriter(output);


//stream tokenizer for input file
StreamTokenizer input = new StreamTokenizer(inputFile);
input.wordChars(0x20,0x7F);
int tokenType;


//set tokentype to the first value in nulls.txt
tokenType = input.nextToken();

//while loop that operates while the tokenType value does not equal the end of the input file. This loop takes the question number and String value from nulls.txt and writes them out in the same position to index.txt, effectively blanking the output file.

while (tokenType !=StreamTokenizer.TT_EOF)
{

question = input.nval;
tokenType = input.nextToken();
name= input.sval;
outputFile.println(question+"\t"+name);
tokenType = input.nextToken();

}


//close file reader and file writer
inputFile.close();
output.close();

}

}
//END OF CLASS