×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    9

    Proble reading from file using RReadStream

    I am trying to read a bunch of floating point numbers from a (text) file and write them to the console using the following piece of code, but it is not working. The program exist upon trying to read for the first time.
    Do I need to do something special if I read from a text file?

    _LIT(KFeatureQueryFileName,"e:\\surf\\test_single.txt");
    RFileReadStream inputFileStream;
    inputFileStream.PushL();
    User::LeaveIfError(inputFileStream.Open(fsSession,KFeatureQueryFileName, EFileRead));
    TReal32 temp;
    for (TInt i=0;i<10;i++) {
    temp=static_cast<TReal32> (inputFileStream.ReadReal32L());
    console->Printf(KFormat2,i,temp);
    }

  2. #2
    Regular Contributor
    Join Date
    Oct 2004
    Location
    Tokyo,Japan
    Posts
    289

    Thumbs up Re: Proble reading from file using RReadStream

    hi radek_grzeszczuk,

    try this code , it works fine, it may help you !

    here i am trying to state that the file you are trying to read must be written in same way as the way you are trying to read.


    _LIT(KFeatureQueryFileName,"e:\\surf\\test_single.txt");


    RFileWriteStream outputFileStream;
    outputFileStream.PushL();
    User::LeaveIfError(outputFileStream.Create(fsSession,KFeatureQueryFileName, EFileWrite|EFileStream));
    TReal32 temp=3.5;
    outputFileStream.WriteReal32L(temp);
    outputFileStream.Pop();
    outputFileStream.Close();



    RFileReadStream inputFileStream;
    inputFileStream.PushL();
    User::LeaveIfError(inputFileStream.Open(fsSession,KFeatureQueryFileName, EFileRead|EFileStream));
    temp=inputFileStream.ReadReal32L();
    inputFileStream.Pop();
    inputFileStream.Close();
    fsSession.Close();


    i hope it may help !

    regards
    nEo
    Last edited by navjotsingh1979; 2007-04-06 at 07:41.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    9

    Re: Proble reading from file using RReadStream

    Thanks nEo,

    I will give it a try. So what do I do if I need to read a file that was not generated by--it is a simple text file containing a bunch of floats...Thanks again.

    Radek

  4. #4
    Regular Contributor
    Join Date
    Oct 2004
    Location
    Tokyo,Japan
    Posts
    289

    Thumbs up Re: Proble reading from file using RReadStream

    hi radek,

    if you want to read a file that was not generated by your code,
    and that file contains a list of floating point numbers , then you need to know the format in which those floating point numbers are stored in that file.

    then i think that you need to read/parse that file character by character
    and fetch/generate your list of floating point numbers.

    for example :

    say you file has a floating point 3.5

    so its 3 character , '3' , '.' and '5'

    so you need to parse then and convert them into a single floating pointing value 3.5 .


    i hope this makes some sense to you.


    regards
    nEo

  5. #5
    Registered User
    Join Date
    Oct 2006
    Posts
    9

    Re: Proble reading from file using RReadStream

    Thanks, it does. I was just hoping there would be an easier way...

Similar Threads

  1. Problem while Reading text file in Nokia3650
    By lalithunt in forum Mobile Java General
    Replies: 5
    Last Post: 2008-07-30, 17:19
  2. Reading a file
    By prakashs in forum Symbian
    Replies: 4
    Last Post: 2007-01-12, 04:35

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×