Problem reading a file from diskdrive

Put your problem here if it does not fit any of the other categories.

Problem reading a file from diskdrive

Postby euphoriaa » Thu Feb 28, 2008 12:20 pm

I m trying to read a file on my disk drive C on windows.
Code appears correct to me but the emulator isn't showing any result.
My application requires me to read the file line by line.
can sb help me out.
thanks in advance.

here's the code :

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. try{
  2.  
  3.                 FileReader fin = new FileReader( "C:\\graph1.txt" );
  4.  
  5.                 BufferedReader graphFile = new BufferedReader( fin );
  6.  
  7.                
  8.  
  9.             String line;
  10.  
  11.            tv.setText("reading  file ...\n");
  12.  
  13.             while( ( line = graphFile.readLine( ) ) != null ){
  14.  
  15.               tv.append(line);
  16.  
  17.                StringTokenizer st = new StringTokenizer( line );
  18.  
  19.  
  20.  
  21.                 try{
  22.  
  23.                    
  24.  
  25.                     String source  = st.nextToken( );
  26.  
  27.                     String dest    = st.nextToken( );
  28.  
  29.                     int    cost    = Integer.parseInt( st.nextToken( ) );
  30.  
  31.                     g.addEdge( source, dest, cost );
  32.  
  33.                 }
  34.  
  35.                 catch( NumberFormatException e )
  36.  
  37.                   {  }
  38.  
  39.              }
  40.  
  41.          }
  42.  
  43.          catch( IOException e ) {  }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4
If you think you can you can,If you think you can't you are right.
euphoriaa
Once Poster
Once Poster
 
Posts: 1
Joined: Thu Feb 28, 2008 12:08 pm
Location: Hyderabad,INDIA

Top

Postby plusminus » Thu Feb 28, 2008 12:44 pm

Hello euphoriaa,

remember you are working on "a fully seperated/emulated device" :!:
The emulator isn't aware of any of your local HDDs.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby cabernet1976 » Fri Feb 29, 2008 1:59 am

Hi euphoriaa,

What plusminus said is exactly right, and you can google in www.anddev.org, then you will find many thread about file, i.e. http://www.anddev.org/working_with_files-t115.html
Upload2Flickr's blog: http://upload2flickr.blogspot.com
cabernet1976
Senior Developer
Senior Developer
 
Posts: 154
Joined: Fri Nov 16, 2007 2:34 am
Location: China

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 14 guests