BINARY FILE- LRAW problem

this question should be asked in ABAP session,
nevertheless, because no one answer at that section,
LRAW have length 1024 
FunctionName : YEMM_ATTACHMENT
COL_NAME    DATA_TYPE   LENGTH
FILE_NAME :     CHAR            200
TLINENO:          CHAR               4
CONTE:            LRAW           1024
in java i can just using this
byte[]  attachfile= file.getBytes();
if a file is bigger than 1024 , how do i store it and pass it to JCO..
do i have to pass line by line of binary code ??
JCO.Table inputAttach=function.getTableParameterList().getTable("SOBATTH");
byte[] file=new byte[10*1024];
if(blnAttach.equalsIgnoreCase("x")==true){            
if(inputAttach.getNumRows()>0){
int lineno=Integer.parseInt(inputAttach.getString("TLINENO"));
for(int k=0;k<lineno;k++){
fileName=inputAttach.getString("FILE_NAME");
file=inputAttach.getByteArray("ATTACHMENT");
//how do i concatenate the bytes that store in several lines
OutMailDetailsBean outMailDet=new OutMailDetailsBean();
outMailDet.setAttachment(file); 
outMailDet.setAttachmentId(getAttachmentId());
outMailDet.setAttachmentName(fileName);
outMailDet.setEmailId(emailId);
beanList2.add(outMailDet);            
Message was edited by:
        yzme yzme
Message was edited by:
        yzme yzme
Message was edited by:
        yzme yzme
Message was edited by:
        yzme yzme
Message was edited by:
        yzme yzme

1) while converting the file ...i download it and open it....
when open, i always get file corrupted , although the file size is same as the original file
any idea ?
ABAP LRAW to java binary
2) This is printed from ABAP
how to i print the same thing in java and do a comparison  i mean the binary code
Row     MANDT     FILE_NAME     TLINENO     CONTE
1          dsn.jar     1     504B0304140008000800A6419334000000000000000000000000090004004D4554412D494E462FFECA00000300504B0708000000000200000000000000504B0304140008000800A6419334000000000000000000000000140000004D4554412D494E462F4D414E49464553542E4D46858F3D0BC23014456703F90F01170B266
2          dsn.jar     2     E86A8F26B3D4982B3A3127AFEDF45E51B06E5E3B9375FEDF19DCB5464FD6151A2583C135098AD10E1A9DA98BFF60B69871DC90C619CB8A4BD13CBE56A736D88944A3B0F1443EE9E8D9ACC2D66514A68B4E230C1D2ED70A7D0A136B8B69229E4D470BC54C99ADE8709184DC66C5E764794A6658381D159CA3293B331F2D53E9B
3          dsn.jar     3     75BCE6C88334E5E173D055EC3D492C2765EB89785CCA756C0B45AEBA2135975912E1D8B2BF5D14075E67C95DC036BC41DB6F22828BBCFD2E0E578AE5051A700B4B4D86BF4037F31BBE896E1685B5846E298AAF89456FE43A7A98CD5ECFBE457488A99EDD55D2731ED5E31A7FE7D6BF966D0FD12AF8366DC2DB68E58B7323DF8
4          dsn.jar     4     FEECA515578654EC529CC3ADB0B985F088F433187BE9B10E923F07F46FFBBA9857BE91F90B504B0708A366CF5960020000B1040000504B03041400080008009B41933400000000000000000000000026000000636F6D2F73756E2F6D61696C2F64736E2F4D756C7469706172745265706F72742E636C617373AD5769705B571
5          dsn.jar     5     8286A5D14CDE3986F7CAE58CF75C3A95F096B6A850ED095050C570623B957B68A94DF6DEBDFF8D314BD1BBB914AB19F7DC54E082A571A1161A89A793D5B9EFE6614225C3099521A898D54565791D38B554A184E58164B66C558489B9F3DC8F9B44F0591F8C56375C0DF3C93085FAF9F2437217CF33CBC38B946219A98591B8E
6          dsn.jar     6     348F63AF5416B9F0551C40E779FC59791EB7F0DC57E5197FCD9E872BD8F243CBF43C647A76508BDA55D4CBB3EFAE3534E8814EC840557D2EC6A9C3293489D3681793555117CAF8D88A7C462DF8DC5F91498ACFDBB0F86F504B0708F2B9A927DE070000F6110000504B03041400080008009B419334000000000000000000000
7          dsn.jar     7     E8FD097D2F49986182D63E7A3D922222B40B0C4E622A341B27AA30AB447E457FB633F50A7D998323CD00F21AAD69E8E4A8D098A6BBB0372864270E71EA39BA539387183860072D9073E8C13C06B0482F6D548186E94FD31D9ADA209A909BAA40CD4EFC8C4186324E1FAC56309CAD60245BC61975F410EF90F5B3743BC4B932C
8          dsn.jar     8     A6A07E617A23BAD2F324ED965B7B20996A229CDA8356FC1991D78899D197D08BBF20F21C619298474CA3898F7EC3F00B326648D073986E78E01442380D8B56AA96DE82B00992AAB046E80FC48A83A95F319C6F743D8394B3F49C21CFC0E302C155F1C6946D7A1723CF104D9DD9C56883357A52CEE308AE61140B24251AB7039
9          dsn.jar     9     CCCBFBF840C1719C50F00D9C10D0446D10A23608711B84A80D42E56D20E2F70A3EC41FD8D44702EE74B26D333B8C14A112E8F5F9C40C1D29A136AC8DE9C399714228A0A5C01488510A2DDA0A94DB0F07142C609197AB0AAEB1E37FE4E524BE29C05FB0A617AAE0A82DC770FF24A0B968782895D2126AAACF4C6426A9E64AD0B
10          dsn.jar     10     2CBDCDE169E23B8F67CAB21025BD4E7C0E124DA49DCF3B6EA2EA02063B6EA02AECF2BBBAB2D8338F9EB0DBEFCEE2AEB0C7EFB9893A4ABADF730375ABA539DA4B3962A67C92164953CB45DC5FCA13241E2A9C2CDAE8C5DBCE0B15918FFE29BB64CA979315C22E21ECE6C26AE4747447BBFC14A050D83D8F9AB087F3C3DF4DAB8
11          dsn.jar     11     34D4628588B303000076070000270000000000000000000000000014190000636F6D2F73756E2F6D61696C2F64736E2F6D756C7469706172745F7265706F72742E636C617373504B010214001400080008009B419334A01611112F0800001F10000029000000000000000000000000001C1D0000636F6D2F73756E2F6D61696
anyone can help me
Message was edited by:
        yzme yzme

Similar Messages

  • Binary File compare - Problem with char 65533

    Hi,
    I tried to copy an sqlite database (a normal text file) out of my *.jar file. The database is in my java project as a resource file. I read every byte and store it directly into the new file, but somewhow it changes 4 Bytes to 65533! The correct values are 2 times 129 and 2 times 144. It's really strange!
    Have you an idea why this happens? Or is there a better way how to copy out a resource file?
    Thank you for your answers.
            URL u = this.getClass().getResource("/database/resources/mydb.sqlite");
            try {
                InputStreamReader in = new InputStreamReader(u.openStream());
                File outputFile = new File("newdb.sqlite");
                FileWriter out = new FileWriter(outputFile);
                BufferedWriter writer = new BufferedWriter(out);
                while ((c = in.read()) != -1) {
                    writer.write(c);
                in.close();
                writer.close();
            } catch(Exception e) {
                jErrorFld.setText(e.toString());
            }

    Writers are for characters not bytes. Use OutputStreams.

  • Please Help on Reading Binary file

    I'm trying to read a binary file and find a string like "DE F0 CA 01"
    i'm new for java and looked in the forum for solution without success
    please help
    best regards
    gebi

    now i can read the binary file, my problem is now to find the position of byte sequence in the file
    here is my code, may be it helps
    import java.io.*;
    public class ReadBinary
         public static void main(String f[])
              FileInputStream fis;
              DataInputStream dis;
              String value;
              char charIn;
              try
                   fis = new FileInputStream(f[0]);
                   dis = new DataInputStream(fis);
                   System.out.println("file " + f[0]);
                   while (dis.available() > 0)
                        value = Integer.toHexString(dis.read());
              catch (EOFException eof)
                   System.out.println("EOF reached");
              catch (IOException ioe)
                   System.out.println("IO Error " + ioe);
    }best regards
    gebi

  • Problem when streaming out a binary file

    Hi,
    I am trying to stream out a binary file to an output stream (not a file, but a socket). My file is a gzip file, and I was initially simply trying to open the
    file, read it to a a byte array, and writing it out to my output stream. However, I got corrupted data at my other end and it took me quite a bit of
    debugging hours to find out why.
    I tried writing to a file the same information I was writing to my output stream but, although my file was correct, my output stream still contained
    corrupted data.
    I think I have finally narrowed down my problem to the fact that when I try to write a 0x00 value to my output stream, everything gets ignored from this
    point until I write a 0x0a byte to my output stream. Obviously this produces corrupted data, since I need all the bytes of my binary file.
    If somebody can direct me as to how to write a 0x00 value to a socket output stream, I would really appreciate your input.
    This is a sample of my code (Right now I am writing byte by byte: not very efficient, but was the only way I found where I was getting a problem):
    // out is of type OutputStream
    if (Zipped){
         // In this case we just have to stream the file out
    File myFile = new File(fileName);
         FileInputStream inputFile = new FileInputStream(myFile);
         FileOutputStream fos = new FileOutputStream(new File("/tmp/zip.gz")); //zip.gz results in a good (not corrupted) file.
         ByteArrayOutputStream out1 = new ByteArrayOutputStream(1024);
         int bytes = (int)myFile.length();
         byte[] buffer = new byte[bytes];
         bytes = inputFile.read(buffer);
         while (bytes != -1) {
              out1.write(buffer,0,bytes);
              bytes = inputFile.read(buffer);
         inputFile.close();
         try {
              int count=0;
              bytes=out1.size();
              while (count<bytes){
                   fos.write(buffer,count,1);
    out.write(buffer,count,1); // when buffer[count] == 0x00, everything after it gets ignored until a 0x0a byte is written.
                   count++;
         } catch (IOException ioe) {
              SysLog.event("IOEXCEPTION: "+ioe);
         } catch (Exception e) {
              SysLog.event("EXCEPTION: "+e);
         fos.flush();
         fos.close();
         out.flush();
    out.close();
         return;
    }

    Actually, I had thought about that and for some time I tried getting rid of some of the header information in the gzipped file, and then I stopped doing that when I realized that part of the gzipped file is a CRC value which I believe is computed taking into account both the data of the file and the header information. If this is the case, then getting rid of part of the header would produce a corrupted file ... but then, I might be wrong in this issue.
    Anyway, to make my application more clear, what I am doing is writing the code for a cgi command which is suppossed to access information from a database, create an xml file, gzip it, and then send it to the client who requested the information.
    Therefore, what I am sending is an xml file (Content-Type: text/xml) in compressed format (Content-Encoding: gzip). Note that if I don't gzip the file and then send it uncompressed to the client, I have no problems. However, for me it is very important to gzip it because the size of the file can get very large and that would just take bandwidth unnecessarily.
    On the other hand, if I try to gunzip the file locally, I have no problem either (the file is not corrupt at the server's end). Therefore, my problem is when I stream it out.
    Any further help would be really appreciated!

  • Problems with binary files

    Hello everybody!
    I'm having deep trouble with reading from binary files.
    I have opened a DataInputStream with a FileInputStream to read the data (which consists of a lot of short-Variables) into my program.
    Then I wondered why the data read is always wrong, until I discovered the core of the problem yesterday night. It seems as if Java reads everything correct, but the 16bit unsigned int data from the file has a problem.
    It seems as if the second byte is written first, that means i.e. the decimal 2352 (Hex: 09 30) is written 30 09, and that wreaks havoc upon my program, because Java interprets this as dec 12297.
    Now I have the following questions:
    1. Is this a kind of one- or two-complement problem?
    2. Is it possible to read this in a byte array (yes), and convert this byte array afterwards into a short variable?
    3. Is it possible to read this kind of data with a Java class?
    Thank you very much in advance,
    Hans Munzel

    Thank you for your quick reply!
    I already thought that this is the right way to solve this. Now I have already looked it up:
    - I have found no class that is able to transform a byte array into a basic data type.
    - The class Integer is able to convert int variables into a Hex string, making it possible to concatenate the Strings in the correct order and convert it.
    - The class Byte is unfortunately NOT able to do this.
    So, I have tried to make a conversion via combinations of toString(), decode(), and parseInt() (and a lot of other methods, too), but this is a) very complicated and b) prone to errors which result normally in a fatal exception.
    So, am I missing something? I am using JDK 1.3.1, and have looked through the java.lang and java.math packages, but I found nothing I can use.
    The only thing close to converting a couple of bytes to a Java datatype is the DataInputStream with its readShort() etc. methods, but is is causing the problem in the first place ...

  • Problem working with binary file

    Hi,
    I have two seperate programs.
    The first one:
    *Reads a  PDF file from disk via InputStreamReader.read(char[])
    *converts it to s String [String.valueOf(char[])]
    connects to other program using Socket and writes the string's bytes to the OutputStream of the Socket (socket.getOutputStream().write(string.getBytes);)
    Second one:
    *Reads the file from socket via BufferedReader.read(char[])
    *converts it to a string via String.valueOf()
    *writes it to a file using FileOutputStream.write(content.getBytes())
    The problem is:
    If the secong program is running on Win2K,the PDF file is opened with no errors but the pages are all blank.But everything is OK if it is running on Unix(IBM AIX java ver 1.3.1)
    First program is always on Win2K.
    I compared the win2k and unix PDF files,some nonprintable chars are displayed as ? in the win2K one,
    what can be the reason? why does the same problem not occur on Unix?
    Some problems are mentioned on web/forums but these are related with browsers or servlets which I am not using in this case.
    Thanks in advance,

    PDF is a binary file.
    You're doing 1 of 2 possible things wrong....
    1) trying to read a binary file as a text file ( string )
    You can't "just read" a binary file as a text file to extra the strings.
    You need to get the binary format, and parse it's format properly to extract the
    string data.
    2) trying to send a binary file across a socket as a string
    You need to read the PDF file as an array of bytes and send them across
    the socket as such. Trying to convert binary data to characters / strings
    is wrong. characters get converted to and from native encoding schemes to
    unicode.... among other problems.
    regards,
    Owen

  • Download ascii file procedure -problem as its getting binary after download

    Hi ,
    I have create a application that will download a file from a customised blob table by calling the procedure below which is as per oracle documentation:
    CREATE OR REPLACE PROCEDURE download_my_file(p_file IN NUMBER) AS
    v_mime VARCHAR2(48);
    v_length NUMBER;
    v_file_name VARCHAR2(400);
    Lob_loc BLOB;
    BEGIN
    SELECT b.MIME_TYPE, a.file_content, a.file_name,A.file_size
    INTO v_mime,lob_loc,v_file_name,v_length
    FROM PCD_PROCESS_TBL a,PCD_CNTL_TBL b
    WHERE a.seq_no =p_file AND ROWNUM<2;
    -- set up HTTP header
    -- use an NVL around the mime type and
    -- if it is a null set it to application/octect
    -- application/octect may launch a download window from windows
    owa_util.mime_header( NVL(v_mime,'text/plain'), FALSE,'ISO-8859-4' );
    -- set the size so the browser knows how much to download
    htp.p('Content-length: ' || v_length);
    -- the filename will be used by the browser if the users does a save as
    htp.p('Content-Disposition: attachment; filename="'||SUBSTR(v_file_name,INSTR(v_file_name,'/')+1)|| '"');
    -- close the headers
    owa_util.http_header_close;
    -- download the BLOB
    wpg_docload.download_file( Lob_loc );
    END download_my_file;
    The problem is that when our process updating the blob table with .dat file from Unix the data getting inserted fine.The file is basically a ascii file. But after downloading this by mime 'text/plain' or 'application/octet' i can see its getting as a binary file and it is not carriage return by a new line.A space like character getting inserted inside each line .
    can anybody please help out of that how can we get rid of this.
    I even change the blob to clob but still the problem persists even for clob the procedure not getting called.
    Thanks in advance,
    Deba

    Sounds like the problem you're having is the mismatch between the Unix text file format and the Windows text file format.
    Specifically, Unix uses LF (line feed) to denote the end of a line, while Windows uses CRLF (two characters, carriage return and line feed).
    If you open the file in Wordpad, you should see it ok.

  • Binary file problem (Read a specific Stream)

    Hi Guys ,
    I have a problem , I want to read a binary files but not the whole binary file. I only want to read one stream.
    Forexample , I have a binar files which has 5 streams. If I only want to read one of the stream what should i do ? How do i get the position of each stream starting and end ?
    The binary file is attached.
    Please note that the file was 5.7mb where as labview message system allows 5.2mb. therfore i uploaded the file on a file host
    http://uploading.com/files/55524a3d/10211001_.raw/
    Thankyou in advance
    Rgs
    M Omar Tariq

    As far as I can understand. You are able to read and decode the file in Labview. But have problems with big files. In such cases. Read the data file in chunked and discard data not needed. You can also make a tool that splits the multi-channel data into separate files in a binary format easy to read from Labview. It is also not needed to have all the data in memory then analyzing the data. Analysis may in many cases be done in chunks.
    Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
    (Sorry no Labview "brag list" so far)

  • Urgent - pls help - Problem while inserting binary file into Oracle DB

    Hi,
    I am trying to insert binary files into a Blob column in a Oracle 10G table.
    The binary files would be uploaded by the web users and hence come as multipart request. I use apache commons upload streaming API to handle it. Finally i am getting a input stream of the uploaded file.
    The JDBC code is
    PreparedStatement ps=conn.prepareStatement("insert into bincontent_table values(?)");
    ps.setBinaryStream(1,inStream,length);
    My problem starts when i try to find the length of the stream. available() method of inputstream does not return the full length of the stream. so i put a loop to read thru the stream and find the length as shown below
    int length=0;
    while((v=inStream.read())!=-1)
    length++;
    Now, though i got the length, my stream pointer has reached the end and i cant reset it(it throws an error if i try).
    So i copied the stream content to a byte array and created an ByteArrayInputStream like this.
    tempByteArray=new byte[length];
    stream.read(tempByteArray,0,length);
    ByteArrayInputStream bais=new ByteArrayInputStream(tempByteArray);
    Now if i pass this bytearray input stream instead of the normal input stream to the prepared statement's setBinaryStream() method it throws an error as
    "ORA-01460: unimplemented or unreasonable conversion requested".
    Now how to solve this?
    My doubts are ,
    1) preparedStatement.setBinaryStream(int parameterIndex, InputStream x, int length) expects an inputstream and its length. if i have the stream how to find its length with out reading the stream?
    2) Also as the length parameter is a integer, what if i have a large binary file whose length runs more than the capacity of integer
    3) Alternatively there is a setBlob(int i, Blob x) in prepared statement. But how to instantiate a Blob object and set it here
    4) Is there any better way to do this.
    Thanks in advance

    "ORA-01460: unimplemented or unreasonable conversion
    requested".When the setBinaryStream method is used, the driver may have to do extra work to determine whether the parameter data should be sent to the server as a LONGVARBINARY or a BLOB (reference: javadoc)
    1) preparedStatement.setBinaryStream(int parameterIndex,
    InputStream x, int length) expects an inputstream and its length. if i
    have the stream how to find its length with out reading the stream?no. stream may have no specified length. i think you have wrong understanding about stream.
    2) Also as the length parameter is a integer, what if i have a large
    binary file whose length runs more than the capacity of integer
    3) Alternatively there is a setBlob(int i, Blob x) in prepared statement.
    But how to instantiate a Blob object and set it here
    4) Is there any better way to do this.use ps.setBlob(1, instream) instead

  • Problems writing a structured binary file...

    Hi Folks,
    I've been working with one of my students to convert this matlab routine into a VI to no avail:
    fwrite(fout,version,'char');
    fwrite(fout,nchar_text,'short');
    % convert wave_text into array of ascii integers
    fwrite(fout,wave_text,'char');
    % output a null character to terminate string
    %count=fwrite(fout,0,'char');
    fwrite(fout,n_bits,'char');
    fwrite(fout,n_bytes,'char');
    fwrite(fout,data_polarity,'char');
    fwrite(fout,user_data,'float');
    fwrite(fout,s_rate,'ulong');
    fwrite(fout,adrange,'float');
    fwrite(fout,n_pts,'long');
    fwrite(fout,wave,'short');
    fclose(fout);
    I've written a VI that can open the files written by this Matlab procedure with no problem (see openfile.VI), however I can't seem to recreate the method for writing this file to binary (writefile.VI).  I think the Matlab approach is very similar to C, and I'm guessing the issue has to do with converting datatypes effectively.  I've been searching the forms and google, but can't seem to come up with the proper solution.  Any pointers would be greatly appreciated!
    Best,
    Jason Gallant
    Attachments:
    writefile.vi ‏27 KB
    openfile.vi ‏26 KB

    crossrulz wrote:
    The additional bytes for the array and string lengths is what is throwing you off.  Even if you turn it off at the Write Binary File, because you built a cluster they will be in there.  You do not want to cluster up your data in this case.  You need to string together a bunch of Write Binary Files, one for each of your parts of data.  Similar to what you had to do in Matlab.
    Great suggestion!  We tried implementing this, and things are looking better.   I've attatched the new VI that implements this.   There still seems to be a problem, however with the datatypes being written.  As mentioned in the previous post, the data written is:
    version   - 'char
    nchar_text, 'short'
    wave_text, 'char'
    n_bits,'char'
    n_bytes,'char'
    data_polarity,'char'
    user_data,'float'
    s_rate,'ulong'
    adrange,'float'
    n_pts,'long'
    wave,'short'
    Should i be typecasting (or something similar) to string in order to make this readable by my previous routine?
    Attachments:
    writefile.vi ‏38 KB

  • Problem saving 2D array to binary file

    I am getting some strange results when trying to write a transposed 2D array of Unisgned 8-bit data to a binary file. Attached is an example program ("071026_ArraySave_Bug.vi") which demonstrates the suspicious behavior.
    The program generates a small 2D array of U8 data, then saves it to two temporary files using two different methods.
    1) Row-by-row: The 2D array is auto-indexed, and the indexed row is written to file at once (with the prepended size option disabled).
    2) Point-by-point: Two For loops are used to auto-index each element and write it to file individually.
    The saved files are then reopened and the data is read into two 1D arrays for display.
    The bug occurs when the generated 2D array is transposed before being saved to file. In the point-by-point method, the data is always saved to the file as desired, i.e. by row or by column depending on whether the data was transposed. However, in the row-by-row method the data is incorrectly saved when the input data is transposed. Without transposing the array, the row-by-row results are correct.
    Saving the array row-by-row is significantly faster for larger arrays, so this method is desired.
    Note that the option to transpose the input data in the attached VI is performed using a case structure with a boolean constant ("Bug Control"). This is important because:
    1) The bug does not occur if the boolean constant is replaced with a control.
    2) The bug does not occur if the case structure is replaced with a "Select" node from the Comparison Palette.
    3) The bug still occurs if the case structure is removed such that the array is always transposed (i.e. keep the True case).
    For now, I have been able to circumvent the bug in practice by transposing the array and then passing it through a Select with a constant True (the False case uses the untransposed array). This allows the faster row-by-row method to be used without error, but requires new memory allocation for the transposed array.
    I will appreciate any help that can be given regarding this problem, or simply confirmation that it is indeed a bug in Labview 8.5. It is worth noting that the same program did not produce any errors when run in Labview 7.
    Thank you for your help,
    David Viggiano
    Attachments:
    071026_ArraySave_Bug.vi ‏29 KB

    This is a known bug (CAR : 4DP855N3) , related to memory management. see this thread
    If I remember well, Altenbach shown somewhere that forcing the transpose operation to produce a copy of the memory was a proper workaround.
    Message Edité par chilly charly le 10-26-2007 08:40 PM
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    071026_ArraySave_Bug[1].png ‏2 KB

  • Problem rendering certain bytes when reading binary file

    I have a two part problem. I am trying to read files of any type from a client and transfer them over a pipe to a UNIX host running a C API. I have this process working for text data just fine however when I try and submit binary data there appears to be some data loss. Most of the file appears to end up on the host but it just isn't as long as the source, nor will it render correctly.
    In investigating this problem I tried to simply output a temporary copy of the transferred file on the client as I was reading the file just to see if my "thinking/process" was correct. The copy of the file ends up the same length but some bytes seem to have been misread. Upon doing a windiff on the source and copy it appears that several characters that are rendered as blocks in the original show up as '?' in the destination file.
    I believe this is an entirely different problem than why I am losing data on the host side but I want to first figure out why this problem is occuring. The below code is how I am reading and writing the binary file. I realize it has some problems with it, it is more of a POC at this point.
               final int BUF_SIZE = 1000;  // 1K
               char[] cBuffer = new char[BUF_SIZE];
               byte[] bBuffer = new byte[BUF_SIZE];
               int read = BUF_SIZE;
               long length = fLocalFile.length();
               FileInputStream fis = new FileInputStream(fLocalFile);
               DataInputStream dis = new DataInputStream(fis);
               FileOutputStream fos = new FileOutputStream("C:\\temp.file", false);
               DataOutputStream dos = new DataOutputStream(fos);
               for (int start = 0; start < length && reply.getSuccess(); start += read)
                   System.out.println("length: " + length + " start: " + start);
                   read = dis.read(bBuffer, 0, BUF_SIZE);
                   // Send the file data
                   String sTemp = sDestName + ":" + new String(bBuffer,0,read);
                   dos.write(bBuffer,0,read);
                   reply = axBridge.execute (Commands.CMD_FILE_TRANSFER_SEND, sTemp);
                dos.close();
            }It seems as if when reading or writing on the data streams some of the characters aren't getting converted correctly. Can anyone help? I've been testing with a PDF if that sheds any light.

    Yes but you ARE converting to a String first which you then send to the axBridge (sTemp!). Try just sending the bytes. You can easily pre-pend the "<filename>:" by sending those first.
    I know that some conversions occur when converting to a String, what they are exactly and what the exact effects are escapes me. Past experience though has taught me to ALWAYS send bytes, with no conversions, what you read is what you send.
    You may need to modify the send/receive protocol so that you send the command first with the filename then the bytes are sent after...
    As for why the file is not being written correctly to: c:\\temp.file, don't know... try the following code, it tends to be one of the "standard" ways of "streaming" data...
         byte buf[] = new byte[bufSize];
         int bRead = -1;
         while ((bRead = in.read (buf)) != -1)
             out.write (buf,
                     0,
                     bRead);
         }     And try just using a FileOutputStream or wrapping in a BufferedOutputStream.

  • Getting problem while editing a binary file

    Hi All,
    I am trying to edit a binary file using Java.The file contain a string that I have to replace with some other string.For exanple let us assume following is the content of the file -
    õgëÓÌ©™ÿÿ ABC õgëÓÌ©™ÿÿ
    Here, I have to replace this ABC(a string) with some other string.Now,if the replace string length is more than 3(the length of exiting string) then, the binary file is generating some blank space at the end.
    My Code::
    //Here I am trying to insert "Hello" in place of "ABC".
    FileInputStream fis = null;
    fis = new FileInputStream(aFile);
    FileOutputStream to = new FileOutputStream(aF);
    byte[] aTes=new byte[1024];
    String str="Hello";
    aTes=str.getBytes();
    byte[] buffer = new byte[4096];
    int bytesRead;
    while ((bytesRead = fis.read(buffer)) != -1) {
    to.write(buffer, 0, 5);
    to.write(aTes);
    to.write(buffer, 5, bytesRead);
    Plesae guide me to solve this problem.
    Regards,
    Soumitra

    Okay. So was that code you posted supposed to be a failed answer to the question, and you need help with fixing it? Because to me it just looks like code which copies a file, with random modifications. It doesn't look for ABC in any way, it uses the magic number "5" for no apparent reason, and the other modifications are buggy too. So clarification of what the code is supposed to be would be helpful.

  • Binary File IO DLL Problem

    Hiii
        I have developed one Binary file Read/Write Vi..  and then i have convert that vi in to DLL......
        Now i tested that DLL Vi  it is showing an error No 74. Actually for Binary write i will convert the Input cluster to Flattern to String and for Binary Read i will convert the output to unflattern to string.. I have attached the TEST.vi for reference
    Attachments:
    Binary Read#Write DLL.vi ‏18 KB
    Binary File Read#Write.vi ‏24 KB
    TEST.vi.vi ‏31 KB

    hi there
    if you want to read the size of the string you have to enable the "append array or string size" at the write file function. or you do not append the size and simply read all bytes.
    in any case you should replace existing files to avoid remaining bytes of larger strings written in prior calls.
    See attachment for details.
    Best regards
    chris
    CL(A)Dly bending G-Force with LabVIEW
    famous last words: "oh my god, it is full of stars!"
    Attachments:
    IO.JPG ‏66 KB
    IO_8.5.vi ‏27 KB

  • Binary file problem

    I am writing to a binary file. My poblem is that i want that the next time it write to the file it will write on a new line. What can i do? Thanks a lot.
    This is the piece of code that writes to the file:
                         File aFile  = new File( "players.dat" );
                         // create an output stream to the file
                         FileOutputStream aFileOutStream = new FileOutputStream ( aFile, true );
                         // create a data output stream to the file output stream
                         DataOutputStream aDataOutStream = new DataOutputStream ( aFileOutStream );
                         // write data to file
                         aDataOutStream.writeUTF(player);
                         aDataOutStream.writeUTF(String.valueOf(percent) );
                         aDataOutStream.writeUTF(type );
                         aFileOutStream.close();

    kopl wrote:
    I am writing to a binary file. My poblem is that i want that the next time it write to the file it will write on a new line. What can i do? Thanks a lot.I'm confused. I'm no expert in I/O, but When I hear "new line" I think "text file"; "new line" and binary files just don't seem to mix properly in my mind.

Maybe you are looking for

  • ITunes 10.5.2.11 doesn't launch for the second time on Windows 7, 64 bit.

    I have iTunes 10.5.2.11(The latest as of now) on a WIndows 7, 64 bit PC. iTunes launches itself properly for the first time after my system boots, but, when I close iTunes and try to open it once again(without booting again), it's like the computer d

  • Zoom buttons in flash for a interactive PDF file

    hi i have created a interactive PDF in indesign CS5 and i'm exporting it as a SWF but my issue is that indesign dose not allow you to create a zoom in and out function: please see example in link http://www.mentalhealthcommission.ca/annualreport/ it

  • HELP! My 3GS wont charge from the mains or be recognised by my computer?!

    Hi, So Im having some similar problems with my Iphone 3GS (16g, white) Literally this afternoon, I noticed it needed a charge, so I tried plugging it into the usual wall socket in which I use, I then noticed it hadnt started its charge. So I moved it

  • Error in extended program check

    Hi, I m getting following error in Extended Program Check.. <b>The current ABAP command is obsolete Tables with headers are no longer supported in the OO context.</b> for the below declaration.. <b>data: I_fieldcatalog type  slis_t_fieldcat_alv WITH

  • Maximum size of a procedure

    Hi all.. I am facing a probem with the debugging of a procedure. The size of the procedure is given below SOURCE_SIZE PARSED_SIZE CODE_SIZE ERROR_SIZE 163624 1292 150380 0 Is this size exceeding standard size. Also this Sp is calling many other SP,s.