June 29th, 2001, 08:50 AM
help!!! passing info to text file
Hello, I am extremely new to java and I just need some basic advice. My company develops statistical models that read from text files. I want
a)people to be able to go to my site enter values into a form and pass those values to a text file.
b)execute the model (nothing special just like calling a regular .exe)
c)display the results from a text file (the model writes to a text file) into the browser
I understand that this is very basic stuff but I need somewhere to start. Could I have some advice? If you could point me to any articles, code, tutorials on this I would really appreciate it.
Servlets will handle those tasks quite easily. Youll have to import java.io.*;
For writing to a file, you could use something like
FileWriter writer = new FileWriter("user/default/file.txt");
BufferedWriter doWrite = new BufferedWriter(writer);
For Reading use something like this
FileReader reader = new FileReader("user/default/file.txt");
BufferedReader doRead BufferedReader(preader);
//Then for each line to read in use
//Once you invoke the readLine() method the pointer automatically hops to the next line, so whatever=doRead.readLine(); will read in the next line without you having to jump to it.
Do a search on google for "doGet" and "getParameter()" for handling forms.
I hope this helped.