Want to save the number -9999 into a binary file

Hello:
I have this function in which I save different numbers (integers or doubles) into a binary file (with another extension) but when i tried to convert -9999 into bytes and then save it in the file ; it saves -9960 not -9999 as it should. I do not know why.
This is my function:
public static void createFile(Double [][] Grid, String txtOutputFile, String[] gridInfoFile){
     Integer[][] intGrid = null ;
     File file = new File(Utils.ChangeFileExt(txtOutputFile, ".myExt"));
     try {
               FileOutputStream file_out = new FileOutputStream(file);
               DataOutputStream data_out = new DataOutputStream(file_out);
               if(gridInfoFile[0].equalsIgnoreCase("1") || gridInfoFile[0].equalsIgnoreCase("1.0")){
                    intGrid = doubleToIntArray(Grid);
          for(int i = 0; i < Grid.length; i++){
               for(int j = 0; j < Grid[0].length; j++){
                    if(gridInfoFile[0].equalsIgnoreCase("1") || gridInfoFile[0].equalsIgnoreCase("1.0")){
                         Byte byte1, byte2;                         
                         byte1 = new Integer (intGrid[i][j] / 256).byteValue();
                         byte2 = new Integer(intGrid[i][j] - (intGrid[i][j] / 256)).byteValue();
                         data_out.write(byte2);
                         data_out.write(byte1);
                    if(gridInfoFile[0].equalsIgnoreCase("2") || gridInfoFile[0].equalsIgnoreCase("2.0")){
                         ByteArrayOutputStream byte_out = new ByteArrayOutputStream ();
                         DataOutputStream data_out2 = new DataOutputStream (byte_out);
                         data_out2.writeFloat(Grid[i][j].floatValue());
                         byte[] bArray = byte_out.toByteArray();
                         data_out.write(bArray[3]);
                         data_out.write(bArray[2]);
                         data_out.write(bArray[1]);
                         data_out.write(bArray[0]);
          }//fin for
          data_out.close();
          } catch (FileNotFoundException e) {
               e.printStackTrace();
          } catch (IOException e) {
               e.printStackTrace();
I had already tried data_out.writeFloat, write, writeInt, etc without any success.
If someone knows the answer , please let me know, will appreciate that. Thank you for your help
magnasound

Since you are using DataOutputStream, why not use some of its more helpful methods, like writeInt?

Similar Messages

  • Main.vi creates 2D Arrays and I want to save the arrays in an microsoft Excel file(e.g engine_1)and in differnt worksheets(e.g. measure_1;measure_2;...)

    main.vi creates 2D Arrays and I want to save the arrays in an microsoft Excel file(e.g engine_1)and in differnt worksheets(e.g. measure_1;measure_2;...)
    The path(Grundpfad)for the excel file should be inserted in the main.vi.

    1. There's a shipping example called Write Table To XL.vi (Help>Find Examples>Communicating with External Applications>ActiveX>Excel) that you can use as a starting point.
    2. Buy the LabVIEW Report Generation Toolkit. Info can be found here.
    3. Search this forum for other examples of writing to Excel.

  • I am writing an applescript and want to paste the clipboard contents into a new file that opens in TextMate. This is what I have so far. The paste is NOT working...

    This is what I have so far:
    tell application "Google Chrome"
      view source of active tab of window 1 -- Or whichever tab you want
      delay 3
              repeat while loading of active tab of window 1
      delay 3
              end repeat
      select all of active tab of window 1 -- Must *always* be the active tab
      copy selection of active tab of window 1
      delay 3
      --          delete tab (active tab index of window 1) of window 1
    end tell
    delay 1
    tell application "TextMate-1.5.9"
      activate
      open
      paste
    end tell
    Paste is not working.

    This works, I am sure that there is a more elegant way??
    # Applescript to copy html of active tab to clipboard and open TextMate and paste source to new document
    tell application "Google Chrome"
              set theURL to URL of active tab of window 1
    view source of active tab of window 1
    delay 3
              repeat while loading of active tab of window 1
      delay 3
              end repeat
    select all of active tab of window 1 -- Must *always* be the active tab
    copy selection of active tab of window 1
    delay 3
    end tell
    do shell script "open -a TextMate"
    delay 3
    tell application "TextMate"
    open
    activate
              tell application "System Events"
      keystroke "a" using {command down}
      keystroke "v" using {command down}
              end tell
    end tell
    tell application "Google Chrome"
    delete tab (active tab index of window 1) of window 1
    end tell

  • Set Adobe Acrobat XI Pro. When I want to save the file in WORD, EXCEL or esporta file into ... immediately throws an error "save as failed to process this document no file was created". What's the problem?

    Set Adobe Acrobat XI Pro. When I want to save the file in WORD, EXCEL or esporta file into ... immediately throws an error "save as failed to process this document no file was created".
    What's the problem?
    Any help in finding a solution is greatly appreciated.
    Thank you,

    Installed AcrobatXI PRO 11.0.09  on seven computers and laptops. Two of them gives an error when you try to save a document in WORD, EXCEL, Power Point, or when exporting to... error: Save failed to process this document. No File was created.
    But all good saves in the format of TXT and jpg.
    I have uninstalled and restored and re-installed and updated and registry cleaned and removed using the special utility Cleaner Tool for Acrobat, but nothing helps.
    On one notebook with Windows 8.1 and Microsoft office 2013, on another laptop with Windows 7 and Microsoft office 2010, the same problem, although there are computers with Windows 7 and Microsoft office 2010 and everything works.
    Tell me where to find the problem and how to solve it.
    Thank you.

  • Dialog Box as "Do you want to save the changes?" in Forms.

    Hi,
    I have 4 datablocks in my forms that corresponds View.
    In the form design, I have a canvas(multiple inserting design) with two buttons that calls the other two blocks.
    Am inserting the records in the following way,
    In first record,
    am entering the value in one block, then a button-press event and so it opens another canvas where I enter some values then return to my main canvas. This is one row.
    But while I try to insert in the second row, there arises the dialog box as "Do you want to save the changes"?
    I should not get that dialog box.
    Please suggest me with the solution.
    Regards,
    Mini

    Thanks for the response,
    Let me clearly explain.
    I have 3 blocks created from view not table.
    I have a canvas in the multiple display layout i.e Number of items displayed is 10.
    In that canvas, I have set the two buttons. the button event is calling another canvas.
    Am inserting a record in the first row in the following sequence.
    Inserting the values for some fields in the main canvas, then entering the button, it opens another canvas that responds to another block, there am entering some values and closing the button event canvas, then returning to my main canvas, then entering the remaining fields with the values, thus my first row ends.
    Now I want to enter the values in the second row, while I navigate from the first Row to the Second row, there arises the dialog box as to save the changes or not?
    I should not get the dialog box.
    Am inserting the values in the database using Insert statements in all the blocks.
    Hope U understand the issue.
    Suggest me with the solution.
    Regards,
    Mini.

  • ABAP Query - Want to limit the number of records to 5

    I have a query based on a a table join (MKPF with MSEG) infoset. I want to limit the number of records to first five.
    How to deal with it?

    select data from tables using join and where conditions....into internal table....
    now move the first 5 records to second internal table and use them...
    or else in ur select statement u can use...
    select  data from tables <join condition> upto 5 rows.
    Message was edited by:
            Ramesh Babu Chirumamilla

  • How to save the form data into adobe db?

    Hi All,
    How to save the form data into adobe db?
    I have designed one xdp file.
    Through processFormSubmission(), I got the submitted form data as Document obj.
    Then I have called the workflow kickoff program.
    code:
    InvocationRequest request = myFactory.createInvocationRequest ("myprocessname", //Specify the long-lived process name
    "invoke", //Specify the operation name
    params, //Specify input values (HashMap obj)
    false); //Create an asynchronous request
    It successfulyy started the workflow, but the submitted form data is not saved anywhere.
    And also, How get the form data from tables?
    Please provide the solution for the above.
    Thanks in advance.
    Regards,
    Saravanan G

    You need to create a process variable of type IN if you want to be able to pass data to your process. Then the params parameter (HashMap) contains a list of all the IN variables with their content that you want to pass to your process. They key is the name of the variable and the value the content. That way you should get it in your process.
    Now LiveCycle will create a column in the database for every process variable, so the content will be saved in the database just by creating that process variable.
    Jasmin

  • When I get a phone call and them want to save the contact, no keyboard comes up to type the name.  How do I fix that?

    When I get a phone call , then want to save the message, no keyboard comes up to type the name.  How do I fix that? 

    You can open the Phone app then tap Recents then the blue 'i" in a blue circle at the right of the number then "Create New Contact" then tap a field such as "First" name and the keyboard should appear.

  • Show the alert 'Do you want to save the changes? after entering each record

    Hi,
    Is there a way to show the alert 'Do you want to save the changes you have made?', after entering each record.
    i.e. as soon as a record is entered, user should be prompted to 'Do you want to save the changes?' the record when they move to the next record.
    I used the below code in Post-Record rigger. Prompt was diplaying fine as per the requirement,but record was not being saved.
    DECLARE
    n_button_selection INTEGER;
    BEGIN
    if :System.Record_Status='INSERT' then
    fnd_message.set_string('Do you want to save the changes?');
    n_button_selection := fnd_message.question('Yes', 'No','Cancel', 1, 2,'question');
    IF n_button_selection = 1 THEN
    forms_ddl('commit_FORM');
    ELSIF n_button_selection = 2 THEN
    RAISE form_trigger_failure;
    ELSE
    NULL;
    END IF;
    end if;
    END;
    I used forms_ddl('commit_FORM') to commit the record. Because we can't us Do-key('commit_form') in post-record trigger. But forms_ddl('commit_FORM') is not working. So can anybody please give some idea regarding this.
    --

    Forms_ddl issues dynamic sql - you cannot call another builtin (like commit_form) within forms_ddl. Check form_status after the call and you will see that it failed.
    Moreover, forms is not able to execute the post and commit process if you issue "forms_ddl('commit');", so this will not be a solution either.
    You could use the When-New-Record-Instance - Trigger, which allows restricted built-ins to be executed, and issue do_key('commit_form');". However, you would have to check the :system.block_status or :system.form_status, because :system.record_status will already hold the new record number.
    Regards,
    Gerd

  • How can I get a pdf. to open in Safari, all i'm getting is a new window with a black, blank page, instead of the pdf., and I don't want to save the file to the desktop, Safari didn't use to do that, and I don't have Adobe in the internet plug in folder.

    How can I get a pdf. to open in Safari, all i'm getting is a new window with a black, blank page, instead of the pdf., and I don't want to save the file to the desktop, Safari didn't use to do that, and I don't have Adobe in the internet plug in folder.

    Hi
    Please take a look to this thread Re: Can I refresh the browser rather than open a new tab?

  • I have a new iPhone for work, set up on a new iTunes account (PC).  I was told i can associate it to my home iTunes account (iMac) but don't know how.  I want to save the work related apps as well.  Any advice?  Thanks

    I have a new iPhone for work, set up on a new iTunes account (PC).  I was told i can associate it to my home iTunes account (iMac) but don't know how.  I want to save the work related apps as well.  Any advice?  Thanks

    Thanks. I messed up with my husbands iphone because I was told the wrong thing. Now everytime I sync his phone it makes it look just like the other phone I had. Do you know how I can fix taht for his phone? Any settings I can turn off that will prevent all of my apps/contacts, etc from auto populating his phone?

  • How to suppress 'Do u want to save the changes?'  When there are no changes

    Hi All,
    I have developed one form,which contains 3 blocks in that 2 are database blocks and one is control block.It's working fine.When I close the form without doing any change also it is showing an alert as 'Do you want to save the changes you have made?'. How can I suppress that alert when I haven't made any change to the form.
    I am displaying one filed in the database block as 'null' until check box is checked.For that I have written code in when-new-block-instance trigger of that block.
    There I wrote SET_RECORD_PROPERTY (GET_BLOCK_PROPERTY (:SYSTEM.TRIGGER_BLOCK, CURRENT_RECORD), :SYSTEM.TRIGGER_BLOCK, STATUS, QUERY_STATUS); also to change the block status as query.
    But it is not working, still I am getting the alert,How can I solve this could anyone please give me a suggestion..
    Thanks in advance.

    So, this functionality can be done through CHECK BOX itself. Why you are making null by WHEN-NEW-BLOCK-INSTANCE. You can just set the update and insert property for that fields and rest things you can control from chexbox. And WHEN-BLOCK-INSTANCE-TRIGGER will fire once when you will access that block. If you want to set the same functionality for each record. Then you must use WHEN-NEW-RECORD-INSTANCE. for ex.
    Trigger = WHEN-NEW-RECORD-INSTANCE (BLOCK-LEVEL)
    Here i will assume that if check box is checked then he can update that fields.
    IF :CHECKBOX='Y' THEN
      SET_ITEM_PROPERTY('BLOCK_NAME.ITEM_NAME',INSERT_ALLOWED,PROPERTY_TRUE);
      SET_ITEM_PROPERTY('BLOCK_NAME.ITEM_NAME',UPDATEABLE,PROPERTY_TRUE);
    ELSE
      SET_ITEM_PROPERTY('BLOCK_NAME.ITEM_NAME',INSERT_ALLOWED,PROPERTY_FALSE);
      SET_ITEM_PROPERTY('BLOCK_NAME.ITEM_NAME',UPDATEABLE,PROPERTY_FALSE);
    END IF;In the above code no need for set value to NULL.
    And on CHECK BOX you can write like this...
    Trigger WHEN-CHECKBOX-CHANGED (ITEM-LEVEL)
    IF :CHECKBOX='Y' THEN
      SET_ITEM_PROPERTY('BLOCK_NAME.ITEM_NAME',INSERT_ALLOWED,PROPERTY_TRUE);
      SET_ITEM_PROPERTY('BLOCK_NAME.ITEM_NAME',UPDATEABLE,PROPERTY_TRUE);
    ELSE
      :FIELD_NAME:=NULL;  -- here if check box is unchecked then it will set value to NULL
      SET_ITEM_PROPERTY('BLOCK_NAME.ITEM_NAME',INSERT_ALLOWED,PROPERTY_FALSE);
      SET_ITEM_PROPERTY('BLOCK_NAME.ITEM_NAME',UPDATEABLE,PROPERTY_FALSE);
    END IF;-Ammad

  • How to avoid the message "Do you want to save the changes you have made?"

    i have 3 forms
    master block
    detail1 block of master
    detail2 block of detail1
    when i go out of detail1 and detail2 blocks after doing some modifications it asks me "Do you want to save the changes you have made"?
    i want to avoid this message as well as my changes should be posted in the database. what is the solution for this big pblm?

    hi
    may be you are trying to modify the database item or reassigning the database item value which is not actually needed.
    try to comment the reassigning database values
    and give clear_form(do_commit);
    most probably u will not get the message again
    Regards
    Rajdeep .A

  • When I try to open a pdf link in my browser I am asked where I want to save the file.  I used to be asked if I wanted to open the file.  How do I get back to being asked if I want to open rather than save?

    When I try to open a pdf link in my browser I am asked where I want to save the file.  I used to be asked if I wanted to open the file.  How do I get back to being asked if I want to open rather than save?

    What browser?

  • HT1553 Hi, I'm stuck at step 9. I don't see my external harddrive when I want to save the DMG backup file. Can you please help me with this? I'm desperate to make this backup! Big thanx in advance!

    Hi, I'm stuck at step 9. I don't see my external harddrive when I want to save the DMG backup file. Can you please help me with this? I'm desperate to make this backup! Big thanx in advance!
    http://support.apple.com/kb/HT1553

    Repair permissions and restart your computer.  If this does not work, zap the pram.  You should now see your external hard drive. 

Maybe you are looking for

  • 3rd Party Plug-ins for Illustrator

    EskoArtwork has a Dynamic Barcode 3rd party plug-in for Illustrator that is listed on the Adobe wesbiste for Illustrator CS6.  I puchased it and downloaded it but during the install I get a message saying it can't find a compatible Adobe Illustrator

  • About Process Scheduler in PS

    Hi one and all what is process scheduler in PS ? My major question is What is the difference b/w Process Monitor and Report Manager Under Process Scheduler ??

  • How to coonfigure CCMS Alerts and Alert Categories and Alert Rules

    How to Configure CCMS Alerts and Alert Categories and Alert Rules....plz give detail description related to these

  • Convert HTML to "word string"`?

    HI, I am using C#.I have a template word doc that contains key tags of the format [FIELD_0], [FIELD_1], etc... I load this document in memory, and then replace those tags with the correct string values. When I am done, I return it to the user. This i

  • Weblogic Assertion Error

    Hello, I have run into the following problem. When running a very long lasting bean transaction on one BEA Weblogic 6.1 SP2 application server I get no errors, but on the other one that in fact should be quite similar to the first one, I get: EJB Exc