Get the binary content of a file

Hello

can someone help me get the binary content to the format string of any file passed as an input.

IM new to the Blackberry Java development so please help me with this.

Any help would be appreciated.

Thank you & best regards

I found the solution.

I used two different functions to get the binary and hexadecimal representation respectively

These two functions are:


// function that returns binary data of file

public String getBits(byte b)
    {
        String result = "";
        for(int i = 0; i < 8; i++)
            result += (b & (1 << i)) == 0 ? "0" : "1";
        return result;
    }
// function that returns hex data of a file and writes it to another file

    public static String byteArrayToHexString(byte[] b) {

        int len = b.length;
        char[] s = new char[len * 2];

        for (int i = 0, j = 0; i < len; i++) {
          int c = ((int) b[i]) & 0xff;

          s[j++] = (char) HEXBYTES[c >> 4 & 0xf];
          s[j++] = (char) HEXBYTES[c & 0xf];
        }

        DataOutputStream os = null;
        FileConnection fcon = null;
        try {
fcon = (FileConnection)Connector.open("file:///store/home/user/hexfeatures.txt",Connector.READ_WRITE);

            fcon.create();
            os = fcon.openDataOutputStream();
            os.writeChars(new String(s));

            os.close();
            fcon.close();

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return new String(s);
      }

Thank you & best regards

Tags: BlackBerry Developers

Similar Questions

  • How can I get the back toolbar that says "file, editing, history, tools, etc.?

    How can I get the back toolbar that says "file, editing, history, tools, etc.?

    Don't see the menu bar (file, publishing, display, history...) (Help)? Hold down the key (key in OSX) and press the following letters in this exact order: V T M
    The bar of menus must now appear permanently, unless you turn it off again (view > toolbars). Turn on/off the menu bar is a new feature in version 3.6.
    See the other bars under view > toolbars. Click on one of them will place a check mark (display) or remove the check mark (not shown).
    To display the status bar, display, and then click status bar to place a control mark (display) or remove the check mark (not shown).

    • If items are missing then see if you can find them in the view > toolbars > customize window.
    • If you see the item in the window customize then bring her back in the window, customize the Navigation toolbar.
    • If you do not see this item then click Restore default set in the view > toolbars > customize window.
  • HDR-CX240... How can I get the camera to record all FILES VIDEO in MP4 format?

    HDR-CX240... How can I get the camera to record all FILES VIDEO in MP4 format. Is this possible? I can't find how to change what default file to save to. Any help would be appreciated.

    Hi dang201,

    There is no option to save the video in mp4 format only. You can check on the MProot folder on your memory card for mp4 files. The. MTS files are normally saved in another folder called flow.

    If my post answered your question, please mark it as "accept as a Solution.

  • How can I get the utility auditor of system files (SFC) in Windows XP to search for the source files on a CD in a CD/DVD EXTERNAL drive instead of the CD/DVD drive internal Windows?

    I use a Dell Dimension E310 PC running Windows XP Media Center Edition.  The CD/DVD drive has stopped recognizing CD long ago.  (He still recognizes DVD but not CD).  I use an external drive to CD/DVD of Asus.  I keep getting messages that Windows need to replace versions unrecognized some Windows file and asks me to insert my source CD into the CD/DVD drive.  I checked the MS Knowledge Base and got instructions on how to use the utility (SFC) System File Checker to replace the unrecognized Windows files.  I started the process and inserted the source of CD files (recovery CD provided by Dell with the PC when I bought it) in the drive of external CD/DVD, but the SFC would not recognize it it.  He just kept asking me to insert the CD of source files in the CD/DVD drive.  So I have to find a way to get the SFC utility to find files in the external CD/DVD drive source - or I have to take the PC to the Geek Squad, buy a new CD/DVD drive and get them to install it.  Would appreciate any help you can provide.

    GO to start > run > regedit
    Access
    HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Setup

    SourcePath = X:

    Where X: is the drive letter of your CD/DVD

  • When I try to open a game (Chess Titans, inkball, etc.), I get the following message: "c:\Program Files\Microsoft Games\Chess\Chess.exe the specified path does not exist.

    When I try to open a game (Chess Titans, inkball, etc.), I get the following message: "c:\Program Files\Microsoft Games\Chess\Chess.exe the specified path does not exist.  Check the path and then try again. "Should I do to get my games back so I can play them?  I've tried enabling/disabling of Windows features, but it did nothing.  I also tried to go through the run, but that has not worked.  And, I tried command prompt, but it says that I am not the administrator, who I am.

    Not accessible games

    I haven't had any changes consciously, and the games do not work in any user account.  When I've done sfc/scannow (command prompt) he said that I was not the administrator.  I could learn from another source to solve this problem - in the start menu, right click on the command prompt icon, and then click Run as administrator.  Hope everybody help with this problem.  If you do not have command prompt in your Start menu, any type of command prompt in your search box and it should appear.

    Anyway, my games work now.  Thank you

  • How to get the path (using &lt; input type = "file" / &gt;)

    Hello world

    I create a HTML form that has an entry of type = "file".  This will give you a dialog box browse for your user to search for a file on the operating system.

    And my code:

    function handleFileSelectForMyShop (evt)
    {
    var blnFileReaderSupported = false;

    Try
    {

    Debug.log ("handleFileSelect", "start handleFileSelect");
    reader of var = new FileReader();
    blnFileReaderSupported = true;
    var files = evt.target.files;
    var size = files.length;

    Debug.log ("handleFileSelect", "handleFileSelect # selected files:" + size, debug.info);

    for (var i = 0; i)< size;="">
    {
    Debug.log ("handleFileSelect", "in the handleFileSelect analysis the index file" + i, debug.info ");
    var f = files [i];
    Reader.OnLoad = (function (theFile)
    {
    Debug.log ("handleFileSelect", "start reader.onload", debug.info);
    return Function
    {
    Debug.log ("handleFileSelect", "start Function", debug.info);

    Debug.log ("handleFileSelect", "reading file" + theFile.name + "(" + theFile.size + "") "" + theFile.type, debug.info);

    If (theFile.type.match ('image.*')) {}
    var path = e.target.result;
    alert (path);
    create the path

    } else {}
    jAlert ("Please select photo!', 'Error'");
    }
    };
    })(f);

    If ((f.type.match ('image.*')) |) (f.type.match ('audio.*')) | (f.type.match ('video.*')))
    {
    Debug.log ("handleFileSelect", "in handleFileSelect call reader.readAsDataURL for type" + f.type, debug.info);
    Read in the media file in the form of a data URL.
    reader.readAsDataURL (f);
    }
    }

    Debug.log ("handleFileSelect", "Complete", debug.info);
    }
    {} catch (e)
    Debug.log ("handleFileSelect", e, debug.exception);
    If (! blnFileReaderSupported)
    {
    Alert('Error.) The FileReader API is not supported. ") ;
    }
    }
    }

    function doPageLoad()
    {
    Try
    {
    ELE var = document.getElementById ('txtFile_staffInfo');
    If (ele)
    {
    ele.addEventListener ('change', handleFileSelectForMyShop, false);
    }
    imgSelectPictureClick = 0;
    }
    {} catch (e)
    Debug.log ("doPageLoad", e, debug.exception);
    }
    }

    window.addEventListener ("load", doPageLoad, false);

    Note: And alert (path) leads to a Base64 string! It is not a path of the image that I browse a Spain file on the operating system.

    I want to have a full path of the file. For example: file:///accounts/1000/appdata/WebWorksAppTemplate.testa3NBcHBUZW1wbGF0ZSAgICA/shared/camera/image01.jpg

    I hope to see your reply soon!

    Thank you and best regards,

    A Pham

    A Pham

    I think that you can not get the absolute path of a file due to browser security, when you use the

    It's something that you need probably a PlayBook extension for.

  • All help & support files have disappeared. I get the message "help and support files cannot start."

    Original title: help & support files

    Windows 7 Professional. All help & support files have disappeared. I get the message "help and support files cannot start."

    How to return please?.

    Perhaps.  An analysis of file system I think would replace the help files, but you can try it, there is no harm.  Just open a command prompt (right click and "open as Administrator"), and then type sfc/scannow

  • How to get the absolute path to a file in photoshop extended?

    Hello

    I try to send a file via an entry inside an extension of Photoshop. But how can I get the absolute path to this file inside the computer?

    Thanks in advance

    I don't know what you mean by sending a file. Do you want to open a file in PS or do I have to declare the path for support for the extension file? With javascript, you must define a variable. In Win it should look like:

    var file = new File('/c/images/myfile.psd');
    

    or

    var myScript = new File(app.path + '/Presets/Scripts/myJavascript.jsx');
    
  • When I run Muse I get the following error message: error [file/deleteFile]: error

    When I run Muse I get the following error message: error [file/deleteFile]: error #3013: file or directory is in use.  I click OK and then it closes.

    NEVER MIND... it seems that error is that if I try to open the Muse by clicking on the file in Web site... If I just opened Muse itself I do not receive the error message.

  • How can I replace the mime types of server, always get the mp3, rar, sid, bin files directly in the dialog box "where do you want to save this file?"

    I used to be able to click on MP3 files, the way back when, and Firefox asks where I wanted to save. Nowadays, it opens a new tab with a flash drive.
    By clicking on the "unknown" files, like .sid, .prg, .zip, .rar is ' this is a BIN file. [Cancel] [Save] ». It does not give me a check box for "always do this".
    I would like that option to edit so that certain types of files, such as PDF, regardless of mimetype, always get opened in a new tab if you click. Also some types of files, based on the extension, always go directly to the dialog box "Where you want to save the file?", without worrying if there is a viewer or a builtin player or not. In my Firefox (41.0.1 14.04LTS 32-bit Ubuntu) I have never the choice "do this for these files always" more.
    Googling led me to delete my file mimeTypes.rdf and since file extensions can even "well known", such as .zip, are treated as BIN files and I get the box Cancel-or-Save for those too - again without the choice of "always save the BIN files.

    These files are send as Content-Type: application/octet-stream and Content-Disposition: attachment;
    To send files in this way, you cannot save an automatic action.
    You can see that in network monitor.

    Content-Disposition: attachment; filename="TURRICAN_AMIGA_PORT.sid";
    Content-Type: application/octet-stream
    
  • How can I get the ul (code 101-8200) file so I can reinstall my printer?

    The printer was working fine until I got the message and the code. I don't know what caused it disappear. I tried to get the file with no luck. Help, please!     Thanks Bev1950

    Are you located in Europe (or attempt to print something that would be more 'normal' for a European country, as for the United States)?

    Kodak http://support.en.kodak.com/app/answers/detail/a_id/31863/kw/101-8200/selected/true says:

    How to solve "The UI File is Missing" error message (error code 101-8200)?

    To resolve the error:

    1. Install the EUupdate.exe file (updated European Union make Expansion) from the Microsoft Web site.
    2. Home Center software installation from the CD that came with your printer or at www.kodak.com/go/aiodownloads.

    If you have the latest version of the software and the error persists, there will be a malicious software on the computer. Run an anti-malware program to identify and remove malicious software.

    If the error persists, contact us.

  • Try to save a copy of the contacts and emails in windows live to get the error cannot create .csv file

    Try saving a copy of contacts and emails in windows live to get the error can not create .csv file any help appreciated.

    First create new folders to the location where you want it on a local hard drive. Then use the Browse button in the Export Wizard to navigate to the files you created. Once the export is complete, copy the files to their final destination.

    Windows Live products and services are not covered by these forums. You will find support, solutions and forums for them to the Windows Live Solution Center. When you ask a question here, you should give your version of the software, because the answers vary depending on the version. In WLMail to find, has press on ALT - H. If it doesn't show you the version and the build number, press on escape to two times, and then Alt - F B.

    Noel

  • Windows DVD Maker Gets the error with a .avi file - the file C:\\...avi is not valid or is corrupted.

    I try to use Windows DVD Maker and copy/convert a file .avi on a DVD and get the following error message when I try to add a .avi file to the queue.  I tried this on multiple .avi files:

    ****************************************************

    0 items added successfully

    1 file could not be added

    The C:\\...avi file is not valid or is corrupted.

    ****************************************************

    Also, I must stress that I have no problem looking at one/play the file on my computer, so I don't think that the file itself is really corrupted.

    I have not downloaded another software to help 'fix' this problem.

    This is my first time you try to use this software to create a DVD...

    Please advise on what I can to help resolve this problem!

    Thank you-

    Hi KK33,.

    I suggest you try the steps suggested by Irfan H, from the following link and check if it helps:

    Invalid or damaged AVI

  • How to write the xml content of a file (Blob data Type) with other columns in file system

    Team,
    We are currently working on oracle 11 g. Suppose that we consider the SCOTT. EMP table for our creation of the table.
    All existing columns of SCOTT along. EMP table allows to assume that this table has an additional column name emp_xml, which is of TYpe of BLOB data and it holds xml data.
    the size of the data blob for each record in this col is greater than 32 KB (normally about 1 GB), now I want to write the contents of this column along
    with enmae, empno, hiredate into an external file. Assume that if we are only to the BLOB column that is emp_xml then the code below works

    Start

    for c in (select emp_xml from your_table)

    loop

    dbms_xslprocessor.clob2file (emp_xml.getclobval (), 'YOUR_LOCATION', 'YOUR_DYNAMIC_FILENAME')
    end loop;
    end;

    but I want empno, enmae, hiredate with blob emp_xml written in the external file. Any assistance in this case welcome.

    Concerning

    max_linesize

    Maximum number of characters for each line, including the newline character,
    for this file (minimum 1, maximum value 32767). If not specified, Oracle
    provides a default value of 1024.

    Defines how much you can read or write to a single call. I have to loop through the clob object and I write a pieces of 1024. So there is no limit to how much she can write. Just test it, IT will WORK!

  • How to get the total runtime of a file of tkprof

    Hello

    I have a file tkprof. How can I get the total execution time. Through the file I guess than the sum of "Total expected" would give the total time in the section "elapsed time are waiting on the following events:

    . Sample tkprof is given below.
    SQL ID: gg52tq1ajzy7t Plan Hash: 3406052038
    
    SELECT POSTED_FLAG 
    FROM
     AP_INVOICE_PAYMENTS WHERE CHECK_ID = :B1 UNION ALL SELECT POSTED_FLAG FROM 
      AP_PAYMENT_HISTORY APH, AP_SYSTEM_PARAMETERS ASP WHERE CHECK_ID = :B1 AND 
      NVL(APH.ORG_ID, -99) = NVL(ASP.ORG_ID, -99) AND 
      (NVL(ASP.WHEN_TO_ACCOUNT_PMT, 'ALWAYS') = 'ALWAYS' OR 
      (NVL(ASP.WHEN_TO_ACCOUNT_PMT, 'ALWAYS') = 'CLEARING ONLY' AND 
      APH.TRANSACTION_TYPE IN ('PAYMENT CLEARING', 'PAYMENT UNCLEARING'))) 
    
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      0.00       0.00          0          0          0           0
    Execute    442      0.08       0.13          0          0          0           0
    Fetch      963      0.22       4.72        350      16955          0         521
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total     1406      0.31       4.85        350      16955          0         521
    
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 173     (recursive depth: 1)
    Number of plan statistics captured: 1
    
    Rows (1st) Rows (avg) Rows (max)  Row Source Operation
    ---------- ---------- ----------  ---------------------------------------------------
             1          1          1  UNION-ALL  (cr=38 pr=3 pw=0 time=139 us)
             1          1          1   TABLE ACCESS BY INDEX ROWID AP_INVOICE_PAYMENTS_ALL (cr=5 pr=0 pw=0 time=124 us cost=6 size=12 card=1)
             1          1          1    INDEX RANGE SCAN AP_INVOICE_PAYMENTS_N2 (cr=4 pr=0 pw=0 time=92 us cost=3 size=0 card=70)(object id 27741)
             0          0          0   NESTED LOOPS  (cr=33 pr=3 pw=0 time=20897 us)
             0          0          0    NESTED LOOPS  (cr=33 pr=3 pw=0 time=20891 us cost=12 size=41 card=1)
             1          1          1     TABLE ACCESS FULL AP_SYSTEM_PARAMETERS_ALL (cr=30 pr=0 pw=0 time=313 us cost=9 size=11 card=1)
             0          0          0     INDEX RANGE SCAN AP_PAYMENT_HISTORY_N1 (cr=3 pr=3 pw=0 time=20568 us cost=2 size=0 card=1)(object id 27834)
             0          0          0    TABLE ACCESS BY INDEX ROWID AP_PAYMENT_HISTORY_ALL (cr=0 pr=0 pw=0 time=0 us cost=3 size=30 card=1)
    
    
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      db file sequential read                       350        0.15          4.33
      Disk file operations I/O                        3        0.00          0.00
      latch: shared pool                              1        0.17          0.17
    ********************************************************************************

    user13019948 wrote:
    Hello

    I have a tkprof file. How can I get the total execution time.
    call count cpu elapsed disk query current rows
    ------- ------ -------- ---------- ---------- ---------- ---------- ----------
    total 1406 0.31 4.85 350 16955 0 521

    TOTAL ELAPSED TIME is 4.85 seconds from line above

Maybe you are looking for