Text File Access on school server help!!!!
I am writing a poll applet for my school website and this is what i have:
import javax.swing.*;
import java.io.*;
import java.util.*;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
//import java.net.URL;
public class Poll extends Applet implements ActionListener
{
static final long serialVersionUID=64154651;
private String input;
private BufferedReader inputStream;
private int option1=0;
private int option2=0;
private int option3=0;
public Poll()
{
}
public void start()
{
setLayout(new GridLayout(3,1));
input=JOptionPane.showInputDialog(null,"Enter your school ID");
Button choice1=new Button("1:Ben is cool");
choice1.setActionCommand("1");
choice1.addActionListener(this);
add(choice1);
Button choice2=new Button("2:Ben is Sweet");
choice2.setActionCommand("2");
choice2.addActionListener(this);
add(choice2);
Button choice3=new Button("3:Ben is Nerdy");
choice3.setActionCommand("3");
choice3.addActionListener(this);
add(choice3);
setVisible(true);
//while(true);
}
public void stop()
{
}
public void actionPerformed(ActionEvent e)
{
String action=e.getActionCommand();
//JOptionPane.showMessageDialog(null,"Action");
try
{
inputStream = new BufferedReader(new FileReader("poll1.txt"));
PrintWriter pw=new PrintWriter(new FileOutputStream("poll3.txt"));
String line= inputStream.readLine();
StringTokenizer st;
while(line!=null)
{
pw.println(line);
st= new StringTokenizer(line);
switch(st.nextToken().charAt(0))
{
case '1':option1++;
break;
case '2':option2++;
break;
case '3':option3++;
break;
}
line=inputStream.readLine();
}
if(action.equals("1"))
{
pw.println("1 "+input);
JOptionPane.showMessageDialog(null,"You voted Ben is cool");
}
if(action.equals("2"))
{
pw.println("2 "+input);
JOptionPane.showMessageDialog(null,"You voted Ben is sweet");
}
if(action.equals("3"))
{
pw.println("3 "+input);
JOptionPane.showMessageDialog(null,"You voted Ben is nerdy");
}
JOptionPane.showMessageDialog(null,"Votes for choice 1: "+option1+"\nVotes for choice 2: "+option2+"\nVotes for choice 3: "+option3);
JOptionPane.showMessageDialog(null,"Thank you for your opinion!");
pw.close();
inputStream.close();
inputStream = new BufferedReader(new FileReader("poll3.txt"));
pw=new PrintWriter(new FileOutputStream("poll1.txt"));
line= inputStream.readLine();
while(line!=null)
{
pw.println(line);
line=inputStream.readLine();
}
pw.close();
}
catch(FileNotFoundException ex)
{
JOptionPane.showMessageDialog(null,"File poll.txt not found.");
System.out.println("File poll1.txt not found.");
}
catch(IOException ex)
{
JOptionPane.showMessageDialog(null,"Error reading from file message.txt.");
System.out.println("Error reading from file message.txt.");
}
catch(Exception ex)
{
JOptionPane.showMessageDialog(null,ex.toString());
}
destroy();
System.exit(0);
}
public static void main(String[] args)
{
Poll p= new Poll();
p.start();
}
}
When I run the applet on the local folder offline in eclipse applet viewer, it works, when I put it on a website, I get a security exception saying that I cant read poll1.txt. How do I read and write to text files that will be up on the same ftp as the class file?

