Hello.
I get a java.lang.NullPointerException when i run my prog. is where i
get the error:
URL u1=new
URL("file",this.hostname,this.hostport,typeField.getText());
data = new Data(u1.getContent());
My objective is to get a string like "c:\1.html" and convert it to a
URL and send it to another chatClient that is connected throught this
jsdt:// protocol... channel, so that this second client can click on
the link received and open the file.
So far i can get the destination client to recieve the text as a
string...any suggestions would be appreciated.
Thomas Fritsch - 30 Nov 2005 13:50 GMT
> I get a java.lang.NullPointerException when i run my prog. is where i
> get the error:
>
> URL u1=new
> URL("file",this.hostname,this.hostport,typeField.getText());
> data = new Data(u1.getContent());
May be typeField is null, and therefore you get the NullPointerException
on typeField.getText(). But this is only a guess, as I don't see the
exception stack trace, because you didn't post it.

Signature
"Thomas:Fritsch$ops:de".replace(':','.').replace('$','@')
Paulus de Boska - 30 Nov 2005 13:59 GMT
Did you initialize hostName ?
Paul Hamaker
http://javalessons.com
Thomas Fritsch - 30 Nov 2005 14:56 GMT
> I get a java.lang.NullPointerException when i run my prog. is where i
> get the error:
>
> URL u1=new
> URL("file",this.hostname,this.hostport,typeField.getText());
BTW: Because hostname and hostport are meaningless for "file" URLs
anyway, you could use this instead of the above:
File file = new File(typeField.getText());
URL u1 = file.toURL();
> data = new Data(u1.getContent());
>
> My objective is to get a string like "c:\1.html" and convert it to a
> URL and ...

Signature
"Thomas:Fritsch$ops:de".replace(':','.').replace('$','@')
Thomas Hawtin - 30 Nov 2005 16:58 GMT
> File file = new File(typeField.getText());
> URL u1 = file.toURL();
file.toURI().toURL() is better, as File.toURL is broken. I don't really
understand why it hasn't been deprecated.
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/