I believe this will always crash because...
> line = s1.readLine().trim();
>
...will most definitly evaluate to null.trim() on the last line.
Dave Yazel
> ----------
> From: grace Wang[SMTP:[EMAIL PROTECTED]]
> Reply To: Discussion list for Java 3D API
> Sent: Thursday, August 24, 2000 2:16 AM
> To: [EMAIL PROTECTED]
> Subject: [JAVA3D] NullPointerException
>
> Hi, everyone,
> This is grace. How are you? I am not fine.
> I got a question for you. I wrote a java file called FF.java in order to
> find all line that have one specific method and then find the receiver
> of
> that method. It seems pretty easy by doing reading file line by line and
> find all lines that have that method. But everytime when I run it always
> give me NullPointerException, I spent three days on it, I still could not
> fix it. Please take a look my code. Thank you! I also made a short file
> (A.java)to be read. the method to be found in A.java is called
> findReceiver.
> --------------------------------error-------------------------------------
> ------
> Exception in thread "main" java.lang.NullPointerException
> at FF.findReceiver(FF.java, Compiled Code)
> at FF.main(FF.java:18)
> --------------------------------source------------------------------------
> -----
> import java.io.*;
> import java.io.File;
> import java.io.FileInputStream;
> import java.io.FileReader;
> import java.io.Reader;
> import java.util.*;
> import java.lang.String;
>
> public class FF
> {
> public static void main(String[] args)
> {
> System.out.println("Input the file name:");
> String fileName = getStr().trim();
> System.out.println("Input the method name:");
> String methodName = getStr().trim();
> //String[] str = findReceiver(fileName, methodName);
> findReceiver(fileName, methodName);
> }//end of main
>
>
> public static void outStr( String S)
> {
> System.out.println( S );
> }
>
> public static String getStr()
> {
> DataInputStream line =
> new DataInputStream(System.in);
> String str = "";
> try
> { str = line.readLine();
> if (str == null) outStr( "null");
> }
> catch (IOException e)
> { outStr( "Error " );
> System.exit(1);
> }
> return str;
> }
>
> public static void findReceiver(String fName, String mName)
> {
> try
> {
> Stack receiverStack= new Stack();
> BufferedReader s1 = new BufferedReader(new FileReader(fName));
>
> String line = s1.readLine().trim();
> System.out.println(line);
> while(!line.equals(""))
> { System.out.println("Input2");
> if (line.indexOf(mName) != -1)
> { System.out.println("3");
> receiverStack.push((Object)line );
> }
> line = s1.readLine().trim();
> System.out.println(line);
> }
>
> s1.close();
> while(!receiverStack.empty())
> {
> System.out.println("Input 4");
> System.out.println(" index: "+ receiverStack.pop());
> }
> }
> catch(IOException exc)
> {
> System.err.println("ERROR: " + exc);
> }
> } //end of findReceiver
>
> }//end of class
>
> --------------------A.java------------------------------------------------
> ------
> public static void main(String[] args)
> {
> System.out.println("Input the file name:");
> String fileName = getStr().trim();
> System.out.println("Input the method name:");
> String methodName = getStr().trim();
> //String[] str = findReceiver(fileName, methodName);
> findReceiver(fileName, methodName);
> }//end of main
>
>
> ________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
>
> ==========================================================================
> =
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> of the message "signoff JAVA3D-INTEREST". For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".