NullPointer Exception in java code (getting Name of File:null output ) -


 public class helloworld   {  public static int executelock; public static int val; public helloworld() {     executelock = 0;     val = 0; } public static void main(string[] args) throws exception {      new helloworld();     new thread(new runnable() {     public void run() {         try{               webfsmanager wfm = new webfsmanager();          }catch(exception e)         {             e.printstacktrace();         }     }                       }).start(); new thread(new runnable() {     public void run() {         try{             while(true){                 thread.sleep(10);                  if(executelock>=2){                       file f = new webfsfile("read.js");                     system.out.println("name of file :"+f.tostring());                     //fileinputstream f1 = new webfsfileinputstream(f);                     //f1.read();                     //f.deleteonexit();                     break;                 }             }                }catch(exception e)         {             e.printstacktrace();         }     }                       }).start();  } }  .........separate file...........................  public class webfsfile extends file  { string filename; boolean fileexists;   public webfsfile(file parent, string child){super(parent,child);} public webfsfile(string parent, string child){super(parent,child);}  public webfsfile(uri uri) {super(uri);}  public webfsfile(string filename) {      super(filename);              string script = "<html><body>hello</body></html>"             webfsmanager.writeinscriptqueue(script, false);      string returnval = webfsmanager.readrawreplyqueue();     if(returnval.equals("error: file or directory not found"))     {         fileexists = false;     }     else if (integer.parseint(returnval)==1){         fileexists = true;     }     else{         throw new webfsclientsideexception(returnval);     }     this.filename = filename;     if(this.filename == null){         throw new nullpointerexception("null object supplied in webfsfile constructor");     }  }  } 

webfsmanager serparate independent class run's jetty server.when instantiate webfsfile class object , catch file object jumps webfsfile constructor , delivers script webfsmanager , replys it.but getting name of file:null output. me

i changed but:

import java.io.*;  public class take {   public static void main(string a[])   {     file t = new try1("hi");     system.out.println("name of file :"+t.tostring());   }    public static class try1 extends file   {     public try1(string name) throws nullpointerexception     {       super(name);     }   } } 

output:

name of file :hi 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -