Discussion Board

Results 1 to 5 of 5
  1. #1
    Regular Contributor Terenas's Avatar
    Join Date
    Apr 2008
    Posts
    57
    Hello,

    I have got a problem for reading datas in a txt file (Nokia 6131). I explain.
    My txt file contains thist :
    Code:
    a032
    010203040506
    Now I've created an InpoutStream and I try to read the datas like hexadecimal values. It means that for the first value I want a0, next is 32, then 01, etc
    Code:
    InputStream fileData = getClass().getResourceAsStream("/data/lafon.txt");
    DataInputStream dataIn = new DataInputStream(fileData);
    Now I'm lost. I tried to read 2 bytes (with dataIn.readByte()) and set the most significant bits with the 1 byte read, and the least with the second byte. But I didn't succeed.


    Could someone help me please.

  2. #2
    Registered User khua's Avatar
    Join Date
    Jul 2007
    Posts
    14
    Hi,
    I think your .txt file has an \r\n after 32.
    and notice that in txt file the char is stored in its ascii code (if isn't unicode).
    then you must get byte, then convert its ascii to hexa aquivalent.

  3. #3
    Regular Contributor Terenas's Avatar
    Join Date
    Apr 2008
    Posts
    57
    You're right there is a \r\n but I can delete it, it could me more easier.
    The problem is that I don't succcess to convert for example the a to its hexadecimal value 0x0a nor a0 to 0xa0.

  4. #4
    Registered User khua's Avatar
    Join Date
    Jul 2007
    Posts
    14
    Hi,
    after you ensured that file isn't unicode, and you can get bytes one by one, check this:

    int ch=0;char hex;
    if((ch = is.read())>-1)
    switch(ch){
    case 48:hex='0';
    case 49:hex='1';
    case 50:hex='2';
    case 51:hex='3';
    //...to 57: hex='9';
    case 97:hex='a';
    case 98:hex='b';
    //..to 102: hex='f'
    }

  5. #5
    Regular Contributor Terenas's Avatar
    Join Date
    Apr 2008
    Posts
    57
    The solution you gave me doesn't work for my case. But thanks anyway.

    I finally succeed byte using an array and doing some calculations.

Similar Threads

  1. [announce] PyUIQ. Python for UIQ 2.1 and 3.x
    By OscarBernabeu in forum Python
    Replies: 35
    Last Post: 2008-01-17, 09:12
  2. Error with makesis.exe and creating the .pkg file
    By gramya87 in forum Symbian Tools & SDKs
    Replies: 7
    Last Post: 2007-10-10, 13:53
  3. Contacts fields order??
    By timatima in forum Symbian C++
    Replies: 1
    Last Post: 2007-06-08, 13:51
  4. Replies: 3
    Last Post: 2007-03-07, 03:36
  5. png file , txt file
    By white_dragon in forum Mobile Java General
    Replies: 0
    Last Post: 2005-08-07, 21:53

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved