Hello ,
I would like to know to read your file on your computer without adb
and push.
best regards,
Niko
On 24 fév, 11:40, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Thanks a lot guys. I got it now. All I did was using adb and push the
> text file into the emulator via cmd prompt everytime i start it. Now
> my code is able to read and store the data exactly as I wanted. Thx
> Dan U, Uizil, Jaeholee.
>
> On Feb 24, 11:40 am, Ulzii <[EMAIL PROTECTED]> wrote:
>
> > Here is my example. I use this code lines.
>
> > try {
> > FileInputStream inFile =
> > openFileInput(fileName);
> > InputStreamReader isr = new
> > InputStreamReader(inFile);
> > BufferedReader in = new
> > BufferedReader(isr);
> > inLine = in.readLine();
> > inFile.close();
>
> > }catch (IOException e) {
> > showAlert("Warning", "Error Exception " +
> > e.toString(), "ok",
> > true);}
>
> > [EMAIL PROTECTED] wrote:
> > > Hi guys,
>
> > > Recently I try to make an android app and somehow I got stucked at
> > > some point where I couldn't come up with a solution yet.
> > > I try to write a method to read a txt file, then store each word read
> > > as a token. Then the tokens are to be stored in arrays. However when i
> > > try to call the method it always jump straight to the 'catch' part as
> > > if it could not read/find the file even tho the path is correctly
> > > specified.
>
> > > Here's the text file format:
> > > HKD Hong-Kong Dollars 0.6235 1.604
>
> > > Here's my code:
> > > public void read()
> > > {
> > > try
> > > {
> > > FileReader f = new FileReader("C:/rates.txt");
> > > BufferedReader in = new BufferedReader(f);
> > > file_status = "updated";
> > > Boolean end = false;
> > > while(!end)
> > > {
>
> > > String s = in.readLine();
> > > if(s==null) end = true;
> > > StringTokenizer st = new StringTokenizer(s);
> > > while(st.hasMoreTokens())
> > > {
> > > code[i] = st.nextToken();
> > > country[i] = st.nextToken();
> > > currency[i] = st.nextToken();
> > > buy[i] = Double.parseDouble(st.nextToken());
> > > sell[i] = Double.parseDouble(st.nextToken());
> > > i++;
> > > }
> > > }
> > > in.close();
> > > }
>
> > > catch(Exception ex)
> > > {
> > > file_status = "File Not Found";
> > > }
> > > }
>
> > > Is there any problem with it? I tested it in DrJava and it works
> > > perfect but not in android platform. Did I miss out something? Or must
> > > I put the txt file in any specific folder? Any helps/advices are
> > > appreciated! Thx in advance :)
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---