Best way to put binary-data into string?

Hi there!
What I want to do is to transfer binary data via HTTP/GET so what I have to do is to transfer binary data into a string.
Currently I do this the follwing way:
      byte[] rawSecData = new byte[4]; //any binary datas
      ByteArrayOutputStream secBOS = new ByteArrayOutputStream(4);
      DataOutputStream secDOS = new DataOutputStream(secBOS);
      for(int i=0; i < rawSecData.length; i++)
        secDOS.writeByte(rawSecData);
secDOS.flush();
String secData = secBOS.toString();
System.err.println("Lenght of resulting String: "+secData.length());
I know that this way already worked fine, however I now set up my system up again with another linux-distro and now strange things happen.
e.g. the secData string differs in lenght from run-to-run between 2 and 4 and I don know at all why?
Transferring the binary-stuff into string-stuff (e.g. short-binary 255 255, String: 65536) is not possible for me because of various reasons.
The funny thing is that I remeber that this already worked some time ago and I can figure out why it now doesnt...
Please help!

First of all thanks a lot for your help!
Yes, I already think its an encoding problem, but how can I specify the encoding in my application in a portable way. I dont have an idea what to do.
My applikation should run as applet on many different 1.1+ VMS (msjvm, netscape-1.1.5, ...).
Thanks again, lg Clemens

Similar Messages

  • What is the best way to insert massive data into an existing excel file?

    dear gurus,
    i am wondering that what is the best way to insert massive data into an existing excel file, more performance perspective.
    the file is read from BDS , and we want to insert data into it .
    the way i can think of is
    1. OLE AUTOMATION
       i think performance will be a big problem
    2. Office integration
        i am not sure it's facing the same performance issue ?
    3 . XXL_SIMPLE_API/FULL_API
        I am not sure whether they can insert data into an existing excel file?
    could you please give me some advices?
    br.
    jun

    Hi,
    If you want to APPEND data( add data to an existing excel file) from SAP, then use GUI_DOWNLOAD fm with APPEND = 'X' paramter.
    Best regards,
    Prashant

  • Best practice for putting binary data on the NMR

    Hi,
    We're creating a component that will consume messages off the NMR, encode them, and subsequently put them back on the NMR. What's the best practice for sending binary data over the NMR?
    1. setContent()?
    2. addAttachment()?
    3. setProperty()?
    If NormailzedMessage.setContent() is the desired approach, then how can you accomplish that?
    Thanks,
    Bruce

    setContent() is used only for XML messages. The recommended way to accommodate binary data is to use addAttachment().

  • What is the best way to put various songs into one album?

    I have been adding album information and album artwork within iTunes to take advantage of cover flow, but i have a lot of songs in my music library that are "stand alone" songs - it is the only song from that artist. I want to put all of these songs together in one album, so all of my miscellaneous rock songs will be put into a Rock Music album or file. I want to do this to eliminate all of the grey boxes within cover flow for all of these songs. When i give the files all the same album name (Rock Music) and album artist (Various Artists) it still does not put them all together within iTunes. It will do it for some, but not all.
    What is the best way to put all of these miscellaneous songs into the same album?

    Try marking all the tracks as part of a compilation. Click on the first track in your list, hold down the shift key and click on the last. Right click anywhere in the selection and choose Get Info, when you are asked if you want to edit multiple items say yes. Change compilation at the bottom of the window to Yes.

  • What's the best way to export UTF8 data into Excel?

    Hi,
    Database charterer set is UTF8
         PARAMETER     VALUE
    1     NLS_NCHAR_CHARACTERSET UTF8
    2     NLS_CHARACTERSET     UTF8
    My requirement is that I want to export oracle data into excel file by using UTL_FILE oracle supplied package.
    But while writing data into excel files it’s looses in UTF8 encoding and writes some garbage data into file.
    I am very much sure that while retrieving the data form database it is perfectly encoded with UTF8, but after data is written to the file it eats the UTF encoding resulting into some garbage data.
    e.g.
    I am retrieving this filed from database which is UTF8 encoded in DB “Langäcker 55” but when it is written into excel it becomes “Langäcker 55”.
    Is Oracle UTL_FILE eating the UTF8 encoding while writing into file? if yes, is there utility which can help me to remain the UTF8 encoding as it is while writing in to excel file? Is there anythingi can do in Oracle to get this done?
    Thanks in advance.
    Thanks,
    Santosh

    Until now I have not found anyone who could write real Excel files (MS binary format) in PL/SQL. So I assume that you write your data in strings separated by a character like ; or |, aka CSV.
    Try to open your file with 'wb' (write binary) instead of 'w' and then use
    -- write data
    utl_file.put_raw(v_file,utl_raw.cast_to_raw(<your data>));
    --write remaining data
    utl_file.fflush(v_file);
    --close the file
    utl_file.fclose(v_file);Regards
    Marcus

  • Best way to migrate Access data into Oracle 10g?

    what's the best and easiest way to migrate MS Access database into Oracle10g?
    Thanks

    you can check out this thread ms access db to oracle 10g
    <p>also as neil mentioned you need an ODBC to established a database connection between ms access and oracle. be sure that the tables are existing in oracle so you move the data from ms access to oracle tables.</p>

  • Best way to extract XML data to DB

    Hello,
    In our work we need to extract data from XML documents into a database. Here are some extra notes:
    + There is no constant schema for the XML documents.
    + Some processing on the XML files is required.
    + The XML documents are very big.
    + The database is Oracle 8i or 9i (Enterprise Edition both) and our framework is NET.
    Our questions are:
    1. What is the best way to extract the data into the database under the above circumstances ?
    2. In case there was a constant schema for the XML documents, would there be a better way ?
    3. Is writing the data to text files first, and then loading it via SQL-Loader is an effective way ?
    Any thoughts would be welcome. Thanks.

    Hi Nicolas,
    The answer depends on your actual storage method (binary, OR, CLOB?), and db version.
    You can try XMLTable, it might be better in this case :
    SELECT x.elem1, x.elem2, ... , x.elem20
    FROM your_table t
       , XMLTable(
          '/an/xpath/to/extract'
          passing t.myxmltype
          columns elem1  varchar2(30) path 'elem1'
                , elem2  varchar2(30) path 'elem2'
                , elem20 varchar2(30) path 'elem20'
         ) x
    ;

  • What is the best way to put LabVIEW DSC data into an Oracle database?

    I have been collecting data using LabVIEW DSC 7.0 for several years and have always accessed the data from the Citadel database via the Historical Data Viewer.  I would now like to begin putting this data into an Oracle database.  My company stores all their data in Oracle and it would provide me all the benefits of their existing infrastructure such as automated backups, data mining tools, etc.
    My initial thought is to use "Read Trace.vi" in LabVIEW to pull historical data from the citadel database at regular intervals (e.g. 1 minute) and insert this data into Oracle via ODBC.  In this way, I do not need to track the value changes in order to know when to write to Oracle.  I also considered replicating the citadel database using some other method, but I recall that the tables used by citadel are somewhat complicated.  I only need a simple table with columns for channel, timestamp, and data.  The "Read Trace.vi" will provide me data in this format.
    I do not need to update the Oracle database in real time, a few minute delay is acceptable. If anyone has a better idea or additional insight please let me know. Thanks.

    In terms of connectivity, you want to use ADO, not ODBC. Beyond that, it all depends on the structure of the data and what you are going to want to do with it. This is a very big question that you need to be getting some in-depth assistance.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • What is the best way to export the data out of BW into a flat file on the S

    Hi All,
    We are BW 7.01 (EHP 1, Service Pack Level 7).
    As part of our BW project scope for our current release, we will be developing certain reports in BW, and for certain reports, the existing legacy reporting system based out of MS Access and the old version of Business Objects Release 2 would be used, with the needed data supplied from the BW system.
    What is the best way to export the data out of BW into a flat file on the Server on regular intervals using a process chain?
    Thanks in advance,
    - Shashi

    Hello Shashi,
    some comments:
    1) An "open hub license" is required for all processes that extract data from BW to a non-SAP system (including APD). Please check with your SAP Account Executive for details.
    2) The limitation of 16 key fields is only valid when using open hub for extracting to a DB table. There's no such limitation when writing files.
    3) Open hub is the recommended solution since it's the easiest to implement, no programming is required, and you don't have to worry much about scaling with higher data volumes (APD and CRM BAPI are quite different in all of these aspects).
    For completeness, here's the most recent documentation which also lists other options:
    http://help.sap.com/saphelp_nw73/helpdata/en/0a/0212b4335542a5ae2ecf9a51fbfc96/frameset.htm
    Regards,
    Marc
    SAP Customer Solution Adoption (CSA)

  • Binary data into a XML

    Hello,
    I'd like to know how I could insert binary data into a XML message, for example, an image.
    Does XML Java API support binary data insertion into a XML message? Or should I make my own classes to do this?
    As I've read in the next url http://www.javaworld.com/javaworld/javatips/jw-javatip117.html ,
    the best approach is to use a Base-64 encoding. The encoding algorithm processes a byte stream in 3-byte sequences. Each 3-byte sequence parcels into four 6-bit data units. Each 6-bit data unit then encodes into the character stream as the corresponding character from the character set: A-Z, a-z, 0-9, +, and /.
    Thanks

    Does XML Java API support binary data insertion into a
    XML message? Or should I make my own classes to do
    this?The XML Java API's support producing well-formed XML according to the XML specifications. Those specifications do not say (or even suggest) how you should encode binary data to put it into XML. If you want to encode your binary data in some way then you are free to do so, but you'll have to write your own code.

  • How-to bind binary data into textbox

    can i bind binary data into the textbox....
    coz..i get human unreadable character
    [B@184b867#     binary data - byte array
    supposingly ..i just need to convert to bytes.toString() to see the content...
    yet i try but..it still return this weird character...any idea...
    OutMailBean outMailBean = new OutMailBean();
    outMailBean.setHost(request.getParameter("SMTP").trim());
    outMailBean.setPort(request.getParameter("port").trim());
    outMailBean.setMessages(request.getParameterValues("message"));    //string[]
    //convert to byte array
    outMailBean.setMessage(util.convertStringBufferToByteArr(bean.getMessages()));
    //insert into table
    Statement stmt = con.createStatement();
    try {
    ResultSet rs = stmt.executeQuery(squery);
    try {
    while (rs.next()) {
    OutMailBean outMailBean = new OutMailBean();
    outMailBean.setEmailId(rs.getString("EMAILID"));
    outMailBean.setDateIn(rs.getString("DATEIN"));
    outMailBean.setMessage(rs.getBytes("MESSAGE"));
    System.err.println(rs.getBytes("MESSAGE").toString());
           //this will return human unreadable form........
    OutMailAckBean outMailAckBean = new OutMailAckBean();
    outMailAckBean.setAckDelivery(rs.getString("ACKDELIVERY"));     
    outMailAckBean.setReceipient(rs.getString("RECEIPIENT"));
    beanList.add(outMailBean);
    beanList.add(outMailAckBean);
                        } finally {
                             rs.close();
                   } finally {
                        stmt.close();
    Message was edited by:
            yzme yzme
    Message was edited by:
            yzme yzme

    Hi yzme,
    You need to convert the binary data to characters, a String, before you can properly display it. You say that <i>System.err.println(rs.getBytes("MESSAGE").toString());</i> prints human unreadable stuff. Maybe you need to use another character encoding, like this
    byte[] message = rs.getBytes("MESSAGE");
    String s = new String(message, "UTF-8"); // or "ISO-8859-1"
    It all depends on how the original email message, presumably text, was stored in the database. There's no general way to convert a byte[] to a String and vice versa.
    BTW, if you populate your OutMailBean using <i>outMailBean.setMessages(request.getParameterValues("message"));</i> then you're actually saying an email can have several messages and OutMailBean contains a <i>String[] messages</i> attribute. Then, you call the <i>outMailBean.setMessage</i> method which implies an email has one message and according to you comment OutMailBean contains a <i>byte[] message</i> attribute. The question is of course how you convert the <i>String[] messages</i> attribute to the <i>byte[] message</i> attribute. In other words, what does <i>util.convertStringBufferToByteArr</i> exactly do? It doesn't even convert a <i>StringBuffer</i>, but a <i>String[]</i>. What you probably want to do is something like
    //OutMailBean bean
    String[] messages = bean.getMessages();
    StringBuffer sb = new StringBuffer();
    for (int j = 0; j < messages.length; j++) {
      sb.append("message ").append(j).append("rn");
      sb.append(messages[j]).append("rnrn");
    bean.setMessage(sb.toString().getBytes("UTF-8"));
    Kind regards,
    Sigiswald

  • Best Way to port the data from one DB to another DB using Biztalk

    Hi,
    please suggest best way to move the data from one db to another DB using biztalk.
    Currently I am doing like that, for each transaction(getting from different source tables) through receive port, and do some mapping (some custom logic for data mapping), then insert to target normalized tables(multiple tables) and back to update the status
    of transaction in source table in sourceDB. It is processing one by one.
    How/best we we can do it using  bulk transfer and update the status. Since it has more than 10000 transaction per call.
    Thanks,
    Vinoth

    Hi Vinoth,
    For SQL Bulk inserts you can always use SQL Bulk Load
    adapter.
    http://www.biztalkgurus.com/biztalk_server/biztalk_blogs/b/biztalksyn/archive/2005/10/23/processing-a-large-flat-file-message-with-biztalk-and-the-sqlbulkinsert-adapter.aspx
    However, even though a SQL Bulk Load adapter can efficiently insert a large amount of data into SQL you are still stuck with the issues of transmitting the
    MessageBox database and the memory issues of dealing with really large messages.
    I would personally suggest you to use SSIS, as you have mentioned that records have to be processed in specific time of day as opposed to when the
    records are available.
    Please refer to this link to get more information about SSIS: http://msdn.microsoft.com/en-us/library/ms141026.aspx
    If you have any more questions related to SSIS, please ask it in
    SSIS 
    forum and you will get specific support.
    Rachit

  • How to convert BLOB data into string format.

    Hi,
    I have problem while converting blob data into string format.
    for example,
    Select dbms_lob.substr(c.shape.Get_wkb(),4000,1) from geotable c
    will get me the first 4000 byte of BLOB .
    When i using SQL as i did above,the max length is 4000, but i can get 32K using plsql as below:
    declare
    my_var CLOB;
    BEGIN
    for x in (Select X from T)
    loop
    my_var:=dbms_lob.substr(x.X,32767,1)
    end loop
    return my_var;
    I comfortably convert 32k BLOB field to string.
    My problem is how to convert blob to varchar having size more than 32K.
    Please help me to resolve this,
    Thanx in advance for the support,
    Nilesh

    Nilesh,
    . . . .The result of get_wkb() will not be human readable (all values are encoded into some binary format).
    SELECT utl_raw.cast_to_varchar2(tbl.geometry.get_wkt()) from FeatureTable tbl;
    -- resulting string:
        ☺AW(⌂özßHAA
    Å\(÷. . . .You may also want to have a look at { dbms_lob | http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_lob.htm#i1015792 } "The DBMS_LOB package provides subprograms to operate on BLOBs, CLOBs, NCLOBs, BFILEs, and temporary LOBs."
    Regards,
    Noel

  • Putting resultset Data into sql server 2000

    hello,
    I have some trouble with putting my Date into the sql server. I'm very confused about this and gives me a lot of headage!
    This is my code:
    public void GenerateAlarms(StringBuffer alarmsLeft) throws Exception
    try
    statement = conn.createStatement();
    rsGenerate = statement.executeQuery("SELECT event_it, oplcl_id, host_id, app_id, sev_id, alarm_id,desc_id, prodef_id, alert_id, date_time FROM ScenarioFive");
    int saveCheck;
    sqlInsert.setInt(1, 1);
    sqlInsert.setDate(2, rsGenerate.getDate(10));
    sqlInsert.setInt(3, 1);
    sqlInsert.setInt(4, 1);
    sqlInsert.setInt(5, 2);
    sqlInsert.setInt(6, 0);
    sqlInsert.setInt(7, 2);
    sqlInsert.setInt(8, 1);
    sqlInsert.setInt(9, 2);
    sqlInsert.setInt(10, 4);
    saveCheck = sqlInsert.executeUpdate();
    if (saveCheck == 0)
    conn.rollback();
    System.out.println("Alarms not Updated in new Database");
    else
    conn.commit();
    rs.deleteRow();
    catch (Exception e)
    System.err.println("Got an exception! ");
    System.err.println(e.getMessage());
    System.out.println("Foult at insert alarms");
    The error is Got an exception!
    [Microsoft][ODBC Driver Manager] Invalid cursor state
    OF course i have a Connection function to the database, I will give this just in case (this one is oke I think)
    public void connection()throws Exception
    String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
    String url = "jdbc:odbc:MSSQL-Storm1";
    String username = "sqldemo";
    String password = "sqldemo";
    Class.forName(driver);
    //Establish the conCection to the database.
    conn = DriverManager.getConnection(url, password, username);
    System.out.println("We are got Connected to STORM: Sql Server Port:1433");
    statement = conn.createStatement();
    conn.setAutoCommit(false);
    Thanks a lot!!

    Not a concern for an Oracle forum.
    Als no need for SHOUTING.
    Conventional solutions are
    - dump the data to a csv file and load it in Mickeysoft SQL server
    - use Oracle Heterogeneous services
    - use Mickeysoft DTS
    Whatever you prefer.
    Sybrand Bakker
    Senior Oracle DBA

  • Best way to edit/update data in JSP ?

    Hi Friends,
    I want to know about Update / Edit data procedure in JSP.
    ie.
    If we have one form having 10 fields, and we need to change only
    1 field then do we require to set update query for all 10 fields ?
    don't it make some overload ?
    Can you give me solution like that ?
    and I want to update data like we use CakePHP scaffold functionality.
    data from database is displayed in field and we just need to edit data
    and save it.
    Can we have such in JSP ? see I don't know struts or any frameworks
    Better you will suggest way to do in JSP.
    for Insert I use Bean [ one java class get the parameters for all fields and query ]
    Please suggest me to set the value to field on edit / update
    and best way to update the data.
    -GkR

    It's easy if you want upade game files, not game engine binary.
    You can make your app that will load swf file. So you can make engine that will load all files externaly from device. Firstly you run app and if it connected by wifi - ask user for upadate wish and that simply download from http files as binary and save they using FileSystem

Maybe you are looking for

  • A Big Thanks.....

    ....to the UK Customer Support team. My daughter's iPhone 5c which we had bought ut of contract from O2, packed in a few weeks ago. After visiting an Apple Store, it was determined that there had been a hardware failure and I was advised to contact O

  • Buy Book doesn't work in iPhoto 6

    I have completed a Photo Book. However, pressing Buy Book does nothing at all. I have bought Apple iPhoto books before without any problems. One-click ordering is enabled for my account in the Apple Store (heard this as one possible solution) and I h

  • User level settengs for Report Painter GR55

    HI All, When user is trying to extract a cost center report from Report Painter GR55. User is not getting the values for few line items for last FI year (2010) and he is able to see the values for current year (2011). Tried with parameters, authoriza

  • Hotmail with Safari. I have an error "This file couldn't be added because it appears to be empty (0 bytes)".

    I use Safari with OS Lion. When I try to attach edited photo in Hotmail I have an error "This file couldn't be added because it appears to be empty (0 bytes)". The same file can be successfully sent from PC with Internet Explorer. How to solve this p

  • Icon images in navigation model

    Version: Spaces PS3 Is it possible to show images (from content server) for navigation menu item in the naivigation model. If anyone done this before please share updates.