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 / March 2005

Tip: Looking for answers? Try searching our database.

Applets, reading data from a file.

Thread view: 
G - 13 Mar 2005 07:54 GMT
Hi there,
 Need help and advice on this. I need to write an applet that read data
from a text file and generates a graph.Below are the  2 methods of reading
the file, which failed.

1)
       try{
       URL url;
       URLConnection urlConn;
       url = new URL("http://myhost.com.sg/mytext.txt");
       urlConn = url.openConnection();
       urlConn.setDoInput(true);
       urlConn.setUseCaches(false);
       DataInputStream dis = new DataInputStream(urlConn.getInputStream());
       String s;
       String[][] tmp = new String[25][50] ;
       int y = 0;
       while ((s=dis.readLine()) != null){
           //System.out.println(i);
           tmp[y] = s.split("\t");
           y++;
       }
       }catch (IOException e) { //do nothing
       }

2)
       try{
       FileInputStream fis = new FileInputStream(f);
       DataInputStream dis = new DataInputStream(fis);
       DataInputStream dis = new DataInputStream(urlConn.getInputStream());
       String s;
       String[][] tmp = new String[25][50] ;
       int y = 0;
       while ((s=dis.readLine()) != null){
           //System.out.println(i);
           tmp[y] = s.split("\t");
           y++;
       }catch (IOException e) { //do nothing
       }
Daniel Tahin - 14 Mar 2005 10:29 GMT
What's the problem with the code?

G schrieb:
> Hi there,
>   Need help and advice on this. I need to write an applet that read data
[quoted text clipped - 35 lines]
>         }catch (IOException e) { //do nothing
>         }
Daniel Dyer - 14 Mar 2005 23:16 GMT
When you say it failed, how did it fail?  Your catch blocks really  
shouldn't be empty, this could be hiding some important information from  
you.  At the very least add an e.printStackTrace() to each one.

Dan.

> Hi there,
>   Need help and advice on this. I need to write an applet that read data
> from a text file and generates a graph.Below are the  2 methods of  
> reading
> the file, which failed.

Signature

Daniel Dyer
http://www.footballpredictions.net



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.