How to read a file with both text and binary data?

For text data I use a BufferedReader,
for binary data I use a DataInputStream.
Since readLine is deprecated in DataInputStream, how can I read in a proper way a file that contains some lines of text followed by some binary data.
Is there a way to do this without writing a new 'readLine' for DataInputStream (that has to take into account the different newlines for Unix en other OS's)?

sorry about that ^
NEW STRING str
WHILE there is stuff in the file DO
    getByte()
    IF reading a string THEN
        WHILE byte is not a return character DO
            convert the byte to character/string
            append char to str
        WEND
    ELSE IF reading raw data THEN
        parse raw data
        do stuff with it
    END IF
WEND

Similar Messages

  • BufferedReader with both text and binary data

    I'm reading ascii data from a socket using the read(char[] cbuf, int off, int len) method for a BufferedReader. This data contains a mixture of text to be parsed and data for an image. The messege is of variable length and the text fields are delimited by markers such as "FOO" or "BAR". I have initialized the BufferedReader in two seperate ways. First is: new BufferedReader(new InputStreamReader(iplCommSocket.getInputStream()));
    The second is : new BufferedReader(new InputStreamReader(iplCommSocket.getInputStream(),"8859_1"));
    If I use the first, I don't think I am getting the data correctly, if I use the second, the string ( creating a new String(char[]) )I get back from the read operation has the text after the binary data clobbered. I've tried converting the char[] to a byte[] and then creating a new String with the byte array using the "8859_1" character encoding to no avail. Any help is greatly appreciated

    Is there a reason that you are using BufferedReader? 'cause, if I were you I wouldn't. It's geared toward text data, not binary data. I would look into some flavor of InputStream or possibly a FileChannel with some clever way to use the ByteBuffer.
    Good Luck
    Lee

  • How to spin an object with both x and z-rotation in M3G?

    I want to spin an object with both x and z-rotation in M3G. I get a good result when I implement this in OpenGL, but the combined rotation doesn't get right when I try to do this in M3G. The x rotation and the z rotation looks like they should when I only use one of them. This is achieved by adding only spinAnimationTrack or rotationAnimationTrack. The problem is that the rotation gets messed up when I add both spinAnimationTrack and rotationAnimationTrack. What am I doing wrong? This is my code:
    KeyframeSequence spinKeyframes =
    new KeyframeSequence(3, 4, KeyframeSequence.SLERP);
    spinKeyframes.setRepeatMode(KeyframeSequence.LOOP);
    spinKeyframes.setDuration(4000);
    spinKeyframes.setKeyframe(0, 0,
    getRotationQuaternion(-50.0f, new float[]{1.0f, 0.0f, 0.0f}));
    spinKeyframes.setKeyframe(1, 2000,
    getRotationQuaternion(50.0f, new float[]{1.0f, 0.0f, 0.0f}));
    spinKeyframes.setKeyframe(2, 4000,
    getRotationQuaternion(-50.0f, new float[]{1.0f, 0.0f, 0.0f}));
    AnimationTrack spinAnimationTrack =
    new AnimationTrack(spinKeyframes,
    AnimationTrack.ORIENTATION);
    AnimationController animatorS = new AnimationController();
    spinAnimationTrack.setController(animatorS);
    animatorS.setSpeed(0.4f * speed, 0);
    KeyframeSequence rotationKeyframes =
    new KeyframeSequence(2, 4, KeyframeSequence.SLERP);
    rotationKeyframes.setRepeatMode(KeyframeSequence.LOOP);
    rotationKeyframes.setDuration(4000);
    rotationKeyframes.setKeyframe(0, 0,
    getRotationQuaternion(359.0f, new float[]{0.0f, 0.0f, 1.0f}));
    rotationKeyframes.setKeyframe(1, 4000,
    getRotationQuaternion(0.0f, new float[]{0.0f, 0.0f, 1.0f}));
    AnimationTrack rotationAnimationTrack1 =
    new AnimationTrack(rotationKeyframes,
    AnimationTrack.ORIENTATION);
    rotationAnimationTrack1.setController(animatorR1);
    animatorR1.setSpeed(0.4f * speed, 0);
    mesh1.addAnimationTrack(spinAnimationTrack);
    mesh1.addAnimationTrack(rotationAnimationTrack1);

    People often make this harder than it is. It's usually not necessary to using clipping paths or to make cuts confined to the areas of overlap to make objects appear to intertwine. Usually, you can simply cut where objects do not overlap. There are no masks, clipping paths, pathfinders, etc., involved in this knot:
    Your specific situation may be somewhat complicated by the use of drop shadows, depending on the specific parameters.
    JET

  • How to burn a dvd with both Mac and Windows files

    I have a DVD that has both Mac and Windows formatted files. When the DVD is mounted only Mac formatted files show. I want to burn a DVD copy containing both formatted files. How do I do that? Thanks in advance.

    Correction! It is a CD and there are two partitions with Mac and Windows files.

  • How to read a file with value of RAW data type? Please help

    Hi Experts,
       I  have a file with RAW data like DE864E48833BFFF1B805001CC4EF4BFA
       I am using GUI_UPLOAD.
       But this FM is throwing error.
       I tried by giving FILETYPE as ASC. The output internal table for this FM contains a field of type c size 32.
       Now it is able to read the file but I want to assign this value to a RAW data type variable.
       This it is unable to do. How to convert the char value to RAW data type?
    Please help!
    Thanks
    Gopal

    Hi,
    The documentation for the function module contains an example for RAW upload.
                begin of itab,
                      raw(255) type x,
                end of itab occurs 0.
               CALL FUNCTION 'GUI_UPLOAD'
               exporting
                  filetype =  'BIN'
                  filename = 'C:\DOWNLOAD.BIN'
               tables
                 data_tab = itab.

  • How to read a file with data in Hierarchical Structure using XSD Schema

    Hi
    We have requirement in which we have to read a FIXED LENGTH file with FILE ADAPTER. File contains the data in hierarchical structure. Hierarchy in the file is identified by the first 3 characters of every line which could be any of these : 000,001,002,003 and 004. Rest files are followed after these. So structure is like:
    000 -- Header of File. Will come only once in file. Length of this line is 43 characters
    -- 001 -- Sub Header. Child for 000. Can repeat in file. Length of this line is 51 characters
    --- 002 -- Detail record. Child for 001. Can repeat multiple times in given 001. Length of this line is 43 characters 1353
    -- 003 -- Sub Footer record at same level of 001. Will always come once with 001 record. Child for 000. Length of this line is 48 characters
    004 -- Footer of file.At same level of 000. Will come only once in file. Length of this line is 48 characters
    Requirement is to create an XSD which should validate this Hierarchical Structure also i.e data should come in this hierarchy only else raise an error while parsing the file.
    Now while configuring the FILE ADAPTER to read this file we are using Native Schema UI to create the XSD to parse this structure using an example data file. But we are not able to create a valid XSD for this file which should validate the Hierarchy also on the file.
    Pls provide any pointers or solution for this.
    Link to download the file, file structure details and XSD that we have created:
    https://docs.google.com/file/d/0B9mCtbxc3m-oUmZuSWRlUTBIcUE/edit?usp=sharing
    Thanks
    Amit Rattan
    Edited by: user11207269 on May 28, 2013 10:16 PM
    Edited by: user11207269 on May 28, 2013 10:31 PM
    Edited by: user11207269 on May 28, 2013 10:33 PM

    Heloo.. Can anyone help me on this. I need to do Hierarchial read / validation while reading the file using File Adapter using Native XSD schema.

  • How to read *.txt files with JSP?

    I have to make a homepage that searches for information on a text file.
    My text file is described below.
    username=Hanako Sony
    cpname=Sony Corporation
    cpcode=500100
    So, if the user inputs "username", then "Hanako Sony" should be returned. If the user inputs "cpname", then "Sony Corporation" should be returned and so on.
    Can anyone help me with this? Can this be done with JSP?
    Thanks,
    Rob

    Try this,
    <%@ page import="java.io.*,java.util.*" %>
    <%
    RandomAccessFile raf = new RandomAccessFile("../webapps/test/jsp/Info.txt","r");
    String qInfo = request.getParameter("qInfo");
    String tInfo="";
    if(qInfo != null) {
         String line="";
         while((line = raf.readLine()) != null) {
              StringTokenizer st = new StringTokenizer(line,"=");
              if(st.hasMoreTokens()) {
                   if(st.nextToken().equalsIgnoreCase(qInfo))
                        tInfo = st.nextToken();
         if(tInfo.equals("")) tInfo="Property Not found ???";
    } else {
         qInfo="";
    %>
    <form name=myform action="" method="get">
    <table><tr>
    <td>What do you want : </td><td><input type = text name="qInfo" value="<%=qInfo%>"></td></tr>
    <tr><td>Here is the information : </td><td><input type = text name="tInfo" value="<%=tInfo%>"></td></tr>
    <tr><td><input type="submit" name"sub"></td></tr>
    </table>
    </form>Here info.txt is your text file. Use the relative path accordingly.
    Hope this helps.
    Sudha

  • How to read .wav files with DIADEM

    I have done a acoustic analysis with a microphone, and I have save the different Files with .wav format.
    I need to read these waveform files with DIADEM.
    Diadem recognize the different files however it returns the message "Diadem d'ont load the files ---.wav"

    Hello Jean-Julien!
    Get and install the Audio Data PlugIn. You can get ist here: http://zone.ni.com/devzone/cda/epd/p/id/44
    Matthias
    Matthias Alleweldt
    Project Engineer / Projektingenieur
    Twigeater?  

  • HOW TO READ TXT FILES with NOKIA 6300?

    I mean:
    I can see pics, video, listen mp3 but I cant read a txt file with Nokia 6300!!
    is there any application to do so? thanks!!!!!!!

    thanks well I tried 4 s far and none works.
    I tried: book_13, read_maniac, tiny-book, plus MobileHeart.com-test-book-831-2336.jar.
    it starts being frustrating.
    Can you suggest one you tested it works?
    -Also, I found that I cant' upload txt file while I can upload *.doc files.....do you know what's happening?
    thanks again.

  • How to read only files with a certain format from folder with java

    I have this folder on the server and I only want to read files from this folder on the server... I only want to read files with the files format starting with error_ and ending with xml... an example of a file would be..
    error_123.xml
    I want something like this
    if(fileName.startsWith("error_") && fileName.endsWith(".xml")){
    but which java package will I have to use to read the file from the directory...

    Create an implementation of the java.io.FilenameFilter interface to match the pattern you need.
    Create a java.io.File object for the folder.
    Use the File.listFiles(FilenameFilter) method to get an array of File objects for the files in the folder that match the pattern.
    For each file in the array, create a FileInputStream, wrap it in an InputStreamReader, and wrap that in a BufferedReader (assuming you want to read the XML files as character streams).

  • How to read Raw files with PS CC

    I installed ps and bridge cc - the programs cannot read raw files (canon 5d mk III and Sony Nex 6). How to fix?

    http://forums.adobe.com/community/bridge
    http://forums.adobe.com/community/photoshop
    This forum is about the Cloud as a delivery process, not about using individual programs
    If you start at the Forums Index http://forums.adobe.com/index.jspa
    You will be able to select a forum for the specific Adobe product(s) you use
    Click the "down arrow" symbol on the right (where it says ALL FORUMS) to open the drop down list and scroll

  • How to read excel file in document library and store excel content in sql table

    Hello,
    Can anyone help me how to read the excel file present in document library and store the content inside excel into sql table?
    Please let me know the ways to acheive this. Feel free to give your suggestions.
    Thanks,
    Cool Developer

    Hi!
    this code i have written becuase i donot find any soltions on net for this , u can try with this . :)
    System.Data.OleDb.
    OleDbConnection ExcelConnection = null;
    FileMode fileMode;
    string filePath = ConfigurationManager.AppSettings["TempLoaction"] + "\\" + fileName;
    using (SPSite _site = new SPSite(SPContext.Current.Web.Url))
    using (SPWeb _web = _site.OpenWeb())
    string docLibrary = ConfigurationManager.AppSettings["DocumentLibrary"];
    SPFile _file = _web.GetFile("/" + docLibrary + "/" + fileName);
    fileMode =
    FileMode.Create;
    byte[] byteArray = _file.OpenBinary();
    MemoryStream dataStream = new MemoryStream(byteArray);
    Stream stream = dataStream;
    using (FileStream fs = File.Open(filePath, fileMode))
    byte[] buffer = new byte[4096];
    int bytesRead;
    while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) != 0)
    fs.Write(buffer, 0, bytesRead);
    fs.Close();
    //Create the Connection String
    try
    string ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;
    Data Source ='"
    + filePath + "'; Extended Properties=Excel 5.0";
    //Create the connection
    ExcelConnection =
    new System.Data.OleDb.OleDbConnection(ConnectionString);
    //create a string for the query
    string ExcelQuery;
    //Sheet1 is the sheet name
    //create the query:
    //read columns from the Excel file
    ExcelQuery =
    "Select * from [Sheet1$]"; // from Sheet1";
    //use "Select * ... " to select the entire sheet
    //create the command
    System.Data.OleDb.
    OleDbCommand ExcelCommand = new System.Data.OleDb.OleDbCommand(ExcelQuery, ExcelConnection);
    //Open the connection
    ExcelConnection.Open();
    //Create a reader
    System.Data.OleDb.
    OleDbDataReader ExcelReader;
    ExcelReader = ExcelCommand.ExecuteReader();
    //For each row after the first
    while (ExcelReader.Read())
    thanks,
    kshitij

  • How to read a file which has header and without header

    Hi,
    I have a file to file scenario wherein there are txt files in the source system, some of which has header and some without header.
    How does the sender adapter dynamically identify a file with header and without header.
    I knew that File content Conversion in the sender adapter with "Recordsets per message = 1" can read the header.  But how to handle dynamically.
    Thanks in advance for suggestions and advice.
    Regards.
    Praveen

    Hi,
    Let me give a more clear picture:-
    One of my file which has header and the corresponding values is listed hereunder:
    PERNR;KID;PNALT;NACHN;NAME2;VORNA;TITEL;TITL2 and so on.....
    ;1200;1200;Angus;; and so on.........
    Other file which has no header but only values in it:-
    1200;1200;;Werner;Angus and so on.......
    The structure remains same for all the files.  The only difference is that some of the file has header in it and some without header.  The Message Type is mentioned hereunder:-
    DT_LegacyEmployee (Category - Complex Type)
         Employees (Category - Element, Occurence - 1)
              Employee (Categroy - Element, Type - DT_LegacyEmployee_Row, Occurence - 0...unbounded)
                   PERNR
                   KID
                   PNALT
                   NACHN
                   NAME2 and so on......     
    I read the file in record row.  The file conversion parameters in the file sender adapter are mentioned hereunder:-
    Document Name - MT_LegacyEmployee
    Document Namespace - http://abc.com/xi
    Recordset Name - Employees
    Rescordset Structure - Employee,*
    Recordsets per Message - 1
    Key Field Type - String (Case Sensitive)
    Employee.fieldSeparator - ;
    Employee.endSeparator - 'nl'
    Employee.fieldNames - PERNR,KID,PNALT,NACHN,NAME2,VORNA,TITEL,TITL2 and so on........
    How do we dynamically identify whether the file has header or not.  Even if the file has header or without header, the file needs to be picked and transferred to the target system.  Kindly clarify.
    Regards.
    Praveen

  • How to read a file containing bitmap message in binary format

    Dear all,
    Can anybody tell me how to read bitmap message which stored data in binary format? The messages are stores like this :
    A file contain some messages along with these bitmaps in square zeroes.
    I want to again convert it into ASCII.

    Double post: http://forum.java.sun.com/thread.jspa?threadID=587497

  • Pie chart with both text and value

    Hi,
    I want the pie chart to contain both the text and value how is this possible when I look at the optiond for chart I was able to select only one thing at a time both not both the things at a time ,please let me know how is this possible
    Thanks
    Priya

    Hi Priya,
    this should be possible. In the Chart Designer in the properties of the Categories you must edit the Format string to e.g. "$Label$br0.00" (show the label, make a line break, show the value with 2 decimals). For more info regarding the format string see note <a href="http://service.sap.com/sap/support/notes/1064448">1064448</a>.
    Best regards
    Matthias

Maybe you are looking for

  • Help reqd to display the form without print preview call

    Hi all, I did one gate pass form and i want to view the form in my selection screen or output screen(just in monitor) as a display by giving one Z-code. i.e, we can view the form thru Print preview...the same preview, i want to display after i give m

  • How do i redownload Mac App store?

    I accidentally deleted the app store from my MacBookPro. How do I re-download Mac App store? Please help

  • Time machine as a media server.

    Can you use Time capsule for Time Machine back up, AND as a Media Server? If I copy my iTunes Library to TC, then change the Music Folder location to TC in iTunes preferences, will Time Machine just back up over it? Over the iTunes library I mean. On

  • Prepayment option

    Hello together, we need a "prepayment" and "cash and carry" payment option in bc? is there a way to do that with bc features? Would be great if anybody have an idea. cheers!

  • IOS 5.0.1 Update - Phone Won't Work (Urgent)

    I just updated my iPhone 4S to iOS 5.0.1. iTunes recommended that I should do this. Anyway over 800 megabytes later, and installing iOS 5.0.1 on my iPhone 4S, it asks me to connect it to iTunes, however once I do it displays a message saying "iTunes