i had a problem of my program it is process completed but it has runtime exception the java.lang.NullPointerException. Anyone can help me ? this is my code so far .
import javax.swing.*;
import java.lang.Character;
import java.io.*;
public class CoproHW
{
public static String c;
public static int NOc;
public static String vince;
public static void main(String args [])throws IOException
{
String vince = JOptionPane.showInputDialog("Enter Your File path :");
c = JOptionPane.showInputDialog("Enter a character");
briefer();
}
public static void briefer()
{
for(int v = 1; v<c.length(); v++)
{
char x = c.charAt(v);
if(Character.isSpaceChar(x))
{
NOc++;
}
char z = c.charAt(v);
if(Character.isLetter(z))
{
NOc++;
}
}
panty();
}
public static void panty()
{
File file = new File(vince);
if(!file.exists())
{
JOptionPane.showMessageDialog(null,"Wrong file path !");
}
else
{
JOptionPane.showMessageDialog(null, "The Number of Characters in "+ c +" is "+ NOc);
try
{
RandomAccessFile gui = new RandomAccessFile(file," ");
gui.writeBytes("The number of Characters in "+ c + " is " +NOc);
gui.close();
}
catch(IOException m)
{
System.out.print(m.getMessage());
System.exit(0);
}
}
}
}