What i'm trying to do here is just place the values in my text file into variables
the txt file contains:
1111
50
2222
60
3333
70
4444
80
5555
90
i get the error :Exception in thread "main" java.lang.NullPointerException
at udptry2.m.readfiless(m.java:41)
at udptry2.m.main(m.java:68)
package udptry2;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.IOException;
/**
*
* @author JAY THE KIDD
*/
public class m
{
BufferedReader in;
BufferedWriter out;
int a;
String[] id;
String[] result;
public void openfile()
{
try{
FileReader inputFile = new FileReader("serverdata.txt");
in = new BufferedReader(inputFile);
}catch(Exception e)
{
System.out.println(e +"File not found");
}//end of catch
}//end of open file
public void readfiless() throws Exception
{
try {
for(int i = 0;i<10;i++)
{
id[i]=in.readLine();
result[i]=in.readLine();
}
} catch (IOException ex) {
System.out.println(ex);
}
for(int i = 0;i<10;i++)
{
System.out.println(id);
System.out.println(result);
}
}
public void closefile() throws IOException
{
in.close();
}//end of close
public static void main(String args[]) throws Exception
{
m r = new m();
r.openfile();
r.readfiless();
r.closefile();
}
}