Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / November 2005

Tip: Looking for answers? Try searching our database.

"getText().toURL" sent to chat client reports NullPointerException

Thread view: 
kubriksCube - 30 Nov 2005 13:27 GMT
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/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.