#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2001
    Posts
    0
    Rep Power
    0

    Question 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.

    Ryan
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2001
    Posts
    0
    Rep Power
    0
    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);
    doWrite.write("Testing");
    doWrite.flush();
    doWrite.close();
    writer.close();

    For Reading use something like this

    FileReader reader = new FileReader("user/default/file.txt");
    BufferedReader doRead BufferedReader(preader);
    String whatever;
    //Then for each line to read in use
    whatever=doRead.readLine();
    doRead.close();
    reader.close();
    //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.

IMN logo majestic logo threadwatch logo seochat tools logo