How to parse binary files

Hi All,
I have one binary file (abc.dat) file I want to parse that file and need it in text format.
Can anyone tell me how can I achieve that? is there any third party tools available?
lines are like below:
00000000h: 76 04 00 01 00 FF 0F 11 FF 09 07 03 15 ; v....
can anyone have idea how can i resolve this?
Thanks!!!

Hi
thanks for reply...
actually what I want is a line that I have posted in first conversation the whole file has lines like that. Now, I want to convert that file in to text format.
right now I am reading lines with the below code...
try{
               FileInputStream fstream = new FileInputStream("test.dat");
               DataInputStream in = new DataInputStream(fstream);
               BufferedReader br = new BufferedReader(new InputStreamReader(in));
               //BufferedInputStream bufferedInputStream = new BufferedInputStream(in);
               String strLine;
//               Read File Line By Line
               while ((strLine = br.readLine()) != null) {
//                Print the content on the console
               System.out.println (strLine);
//               Close the input stream
               in.close();
               }catch (Exception e){//Catch exception if any
               System.err.println("Error: " + e.getMessage());
               }and I don't get output in the text format.
So, after doing this can anyone please tell me how can I get decoded format file?
what are the next steps I should go?
For, example we can go for (index.dat) file.
Thanks!!!

Similar Messages

  • How to upload binary file in database?

    Using servlets..how to upload binary file into database...
    How to get the data of file in servlet...
    Please reply...i'm unable to find exact code...that i want..

    You need to do two separate parts: accept the file from a HTTP multi-part POST and then stream it into a BLOB on the database. To do the former, download Jakarta Commons FileUpload. There is extensive documentation on how to write a simple handler for the upload. You then need to send the data to a BLOB. The specifics vary from database to database but generally you will insert or update a row with an empty blob, get a reference to the blob, pipe the data and then commit.
    If you do a quick forum search, this question has been asked (and answered) dozens of times. Some of the replies may even have code for you. Best of luck.
    - Saish

  • How to parse json files

    Hi
    Can anyone help with some In depth tutorials on how to parse json files locally (in the project folder) and online (webservice) in WP8 development
    Thank you in advance
    Jayjay john

    1. Build up a strong type class for this json
    Visual Studio 2013 Hidden Gem: Paste JSON or XML as C# Classes
    2. use Json.Net to Deserialize , like:
    var result = Newtonsoft.Json.JsonConvert.DeserializeObject<yourdatatype>(jsonstring);
    Working with JSON in C#
    在現實生活中,你和誰在一起的確很重要,甚至能改變你的成長軌跡,決定你的人生成敗。 和什麼樣的人在一起,就會有什麼樣的人生。 和勤奮的人在一起,你不會懶惰; 和積極的人在一起,你不會消沈; 與智者同行,你會不同凡響; 與高人為伍,你能登上巔峰。

  • How to parse xml file, containing image,  generaged from JAX-RS connector?

    Hi,
    We are using JAX-RS connector and just want to call getBusinessObjects() directly using JerseyMe (basically bypassing sync engine). We have used sync engine so far and want to try as how to bypass it. The method produces the text/xml and verified the xml file in the web by giving the full url. The plan is to call the same URL from the Java Me Client using JerseyMe. When I print the bytes at the client I receive the same xml that I have seen in the web. Actually, I am passing an image that I can see in a different character format in xml (assuming this is bcos of UTF-8 encoding). I am wondering as how to parse this xml file and how to decode the "UTF-8" format? Do we need to use SGMP for this or use kxml or java me webservices spec.
    I would really appreciate if somebody can answer this one.
    I have been observing in this forum that SGMP team is not at all active in answering the questions. Please let us know whether Oracle is keeping this product and we can continue using SGMP1.1. Please let us know so that we can plan accordingly as we are building a product based on SGMP.

    Hi Rajiv,
    The client library is using org.apache.commons.codec.binary.Base64 internally. We don't have the full Commons Codec library bundled, but you can look up the javadoc for the Base64 class online. All you need to do is call Base64.decode(obj.getBytes()) on the objects you get out of the XML.
    In general it isn't a good idea to depend on implementation details of the client library, but in this case, I think it is pretty safe to expect org.apache.commons.codec.binary.Base64 to remain in our library.
    --Ryan                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Parsing binary file- unsigned longs

    Hello everyone.
    I'm currently trying to write a quick parser for a binary file format (ASF). However, java's handling of bit shifting and lack of unsigned types is driving me completely mad.
    How can I represent an unsigned long?
    How can I set the bits for it anyway? It seems that the shift operator can't shift more than an int's worth (it just loops around and starts adding to the other bits- weird).
    Thanks in advance.
    Simon

    ejp wrote:
    But why in the world does the following code also do nothing?
    long x = 45 << 32;
    Try long x = 45L << 32;
    The answer appears to be that java uses ints to represent all constants, but this presents some serious problems- namely- how on earth do you get a number bigger than an int into a long?With 'L'. Same as in C or C++. In Visual Basic it's '&'. There's generally something.Where did that come from? Why have I never seen anything like that before?
    If I do long x = 0x7FFFFFFF; all is well, but if I do long x = 0x80000000; I get FFFFFFFF80000000, which isn't what I asked for.Actually it is exactly what you asked for. You've overlooked several facts: (i) Java longs are 64 bits; (ii) you specified a negative 32-bit constant; (iii) the rules of every programming language I can think of provide for sign-extension when going from a shorter to a longer type.Right. It makes sense now that I know how to specify long constants.
    As someone pointed out signed/unsigned is actually the same, so long as you interpret it correctly. So to avoid the total stupidity of using twice as much memory for everything I've decided that I am actually going to use the correct types.They're not the correct types. As I pointed out in an earlier post, your 'unsigned longs' must be coming from C or C++ where they are generally 32 bits, so using a 64-bit Java long is incorrect.Where they came from doesn't matter. The spec doesn't say it's a "long"- it says that this particular value is 64bit, and that all values are unsigned. So I do need a Java long.
    WHY IN THE WORLD IS JAVA "INTELLIGENT" WHEN DOING THINGS BITWISE? WHICH BRAIN DEAD IDIOT THOUGHT THAT UP? That is broken and is asking for trouble.It is you who is asking for trouble here. The rules of Java are consistent and in conformity with the practice in other programming languages. You've just overlooked several relevant facts.I think I've worked out where I was going wrong here. When doing something like
    int i;
    long x;
    x = x | i;The i is converted to a long before the bitwise operation, so it's not the bitwise operation that's the problem, it's the conversion between int and long?
    It's not Java whose stupidity is the issue here ;-)That wouldn't surprise me.
    Thanks.

  • How to handle binary file at the time of import in javacvs

    hi ,
    I am using netbean api for cvs command.I am having the same problem that i am not able to open binary file after importing in cvs repository.
    I want to import a directory which contain both text and binary file.
    can you please hel me out to how to import a directory which contain binary files.
    MY CODES
    ImportCommand command = new ImportCommand();
    Map wrapperMap = new HashMap();
    String filenamePattern="*.ppt";
    KeywordSubstitutionOptions keywordSubstitutionOptions;
    Object b= KeywordSubstitutionOptions.BINARY;
    wrapperMap.put(new SimpleStringPattern(filenamePattern),b);
    command.addWrapper(filenamePattern,org.netbeans.lib.cvsclient.command.KeywordSubstitutionOptions.BINARY);
    command.setWrappers(wrapperMap);
    command.setModule(module);
    command.setLogMessage(comment);
    command.setReleaseTag(releaseTag);
    command.setImportDirectory(path);
    client.setLocalPath(path);
    command.setVendorTag(vendorTag);
    result = client.executeCommand(command, globalOptions);
    Regards
    ruchira

    Please don't cross post.
    http://forum.java.sun.com/thread.jspa?threadID=5127696&tstart=0

  • How to convert binary file to a particular format?

    Hi,
    I am having a requirement. I have in database various kinds of files stored as binary format. Its a sybase database. Now the files can be .pdf, or .doc also. But they are stored in binary format.
    I need to read the file from database.
    Now I can use jdbc to read the particular column value which contains the file in binary format.
    But tricky part is how to convert the binary file entry in a proper respective file format? So I have another column which basically has the value to tell the type of file. So I have ".doc" or ".pdf" as each entry of file...
    So please help me how can we do this using Java?
    THanks

    Hi,
    I am having a requirement. I have in database various
    kinds of files stored as binary format. Its a sybase
    database. Now the files can be .pdf, or .doc also.
    But they are stored in binary format.
    I need to read the file from database.
    Now I can use jdbc to read the particular column
    value which contains the file in binary format.
    But tricky part is how to convert the binary file
    entry in a proper respective file format? So I have
    another column which basically has the value to tell
    the type of file. So I have ".doc" or ".pdf" as each
    entry of file...
    So please help me how can we do this using Java?
    THanks

  • How to parse xml file

    Hi,
    I am having an XML file which is having set of repeated tags like
    <gender>
    <male>
    <name>sk</name>
    <age>19</age>
    </male>
    <male>
    <name>raj</name>
    <age>20</age>
    </male>
    <male>
    <name>kris</name>
    <age>18</age>
    </male>
    </gender>
    Like this i am having the xml file, i have to read the values from this xml file, here we are having male tag is repeated, from this i have to take the name, and age values. can you tell me how to take these values. If you are having the sample send me.
    Thanks,

    Hai
    It may be a bit late to reply but i hope this code will help you
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import java.io.*;
    import java.io.File;
    import org.w3c.dom.*;
    class DomParse
         public void func()
              try               
                   DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();               
                   DocumentBuilder db = dbf.newDocumentBuilder();               
                   //File f =new File("trial.xml");
                   Document doc = db.parse(new File("trial.xml")); //your xml file name here
                   //Document doc = db.parse(f);
                   NodeList nl1 = doc.getElementsByTagName("male");
                   for(int i=0;i<nl1.getLength();i++)
                        Node nd = nl1.item(i);
                        NodeList tmplist = nd.getChildNodes();
                        for(int j=0;j<tmplist.getLength();j++)
                             Node tmpNode = tmplist.item(j);
                             String locStr = tmpNode.getTextContent();
                             System.out.println(""+tmpNode.getTextContent());
              catch(Exception e)
                   System.out.println("Error: "+e);
                   e.printStackTrace();
         public static void main(String[] args) //throws
              new DomParse().func();
    with regards
    shan

  • How to parse XML file with namesapce?

    Hi,
       I am trying to parse an xml file having namespace. But no data is returned.
    Sample Code:
    public class XMLFileLoader
    var xml:XML = new XML();
    var myXML:XML = new XML();
    var XML_URL:String = "file:///C:/Documents and Settings/Administrator/Desktop/MyData.xml";
    var myLoader:URLLoader = null;
    public function XMLFileLoader()
    var myXMLURL:URLRequest = new URLRequest(XML_URL);
    myLoader= new URLLoader(myXMLURL);
    myLoader.addEventListener(Event.COMPLETE,download);
    public function download(event:Event):void
    myXML = XML(myLoader.data);
    var ns:Namespace=myXML.namespace("xsi");
    for(var prop:String in myXML)
         trace(prop);
    //Alert.show(myXML..Parameters);
    //trace("Data loadedww."+myXML.toString());
    //Alert.show(myXML.DocumentInfo.attributes()+"test","Message");
    The XML Contains the following format.
    <Network xmlns="http://www.test.com/2005/test/omc/conf"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://www.test.com/2005/test/omc/conf/TestConfigurationEdition3proposal4.xsd">
        <TestDomain>
          <WAC>
            <!--Release Parameter  -->
            <Parameters ParameterName="ne_release" OutageType="None"
                        accessRight="CreateOnly" isMandatory="true"
                        Planned="false"
                        Reference="true" Working="true">
              <DataType>
                <StringType/>
              </DataType>
              <GUIInfo graphicalName="Release"
                       tabName="All"
                       description="Describes the release version of the managed object"/>
            </Parameters>
    </TestDomain>
    </Network>
    Any sample code how to parse this kind of xml file with namespaces...
    Regards,
    Purushotham

    i have exactly the same problem with KXml2, but using a j2me-polish netbeans project.
    i've tried to work around with similar ways like you, but none of them worked. now i've spent 3 days for solving this problem, i'm a bit disappointed :( what is wrong with setting the downloaded kxml2 jar path in libraries&resources?
    screenshot

  • How to parse XML files from normal FTP Servers?

    I want to parse xml files from a normal FTP Servers , NOT the sap application severs itself. How can i do that?
    I know how to use the SAPFTP getting and putting files ,but I don't want to download and then parse it.
    Who knows how to parse it directly? I Just need to read the contents into a database.
    Thanks.

    I want to parse xml files from a normal FTP Servers , NOT the sap application severs itself. How can i do that?
    I know how to use the SAPFTP getting and putting files ,but I don't want to download and then parse it.
    Who knows how to parse it directly? I Just need to read the contents into a database.
    Thanks.

  • How to Convert binary file to s-records

    Hi all,
    can anybody help how to convert binary ".bin" files to s-record ".s" files
    any idea or code snippets are very appreciated
    best regards,
    gebi

    There is a ready-made converter: "BINARY to Motorola S-Record Conveter Utility" or BIN2MOT.
    http://www.keil.com/download/docs/bin2mot.zip.asp
    Other references:
    http://www.cs.net/lucid/moto.htm
    http://www.amelek.gda.pl/avr/uisp/srecord.htm
    http://www.seattlerobotics.org/encoder/jun99/dougl.html
    http://semmix.pl/mipc/specyf/filehex/mhexu.htm
    http://pmon.groupbsd.org/Info/srec.htm

  • How to parse xml file in midlet

    Hi Guys,
    i wish to parse xml file and display it in my midlet. i found api's supporting xml parsing in j2se ie., in java.net or j2se 5.0. Can u please help me what package to use in midlet?
    how to parse xml info and display in midlet? Plz reply soon......Thanks in advance....

    i have exactly the same problem with KXml2, but using a j2me-polish netbeans project.
    i've tried to work around with similar ways like you, but none of them worked. now i've spent 3 days for solving this problem, i'm a bit disappointed :( what is wrong with setting the downloaded kxml2 jar path in libraries&resources?
    screenshot

  • How to read binary file in Matlab

    "Hello all!
    Labview 7.0 has an example "Cont Acq to File (binary).vi" log the PCI 6014 card and writes the data to a binary file. How can I read that
    file in Matlab(6.5.0... R13)? Does anyone have a solution for this?

    Hello,
    Basically you can do it by saving the data in a file in MATLAB and reading it directly from LabVIEW, or vice versa. In MATLAB , the command "save" allows you to save the data in binary format (*.mat) or ASCII format. You also have an option of saving it in ASCII format using a tab delimiter between data points.
    There is a knowledge base which talks in detail about how to share data in between labview and matlab Import data from labview to Matlab and vice versa.
    Hope this helps. If not, please feel free to ask more questions.
    Good luck and have a great day!
    Koninika
    National Instruments

  • How to read binary file ?

    Hi All,
    I want to read a binary file which has double data. The first byte is an unsigned byte. I have tried using DataInputStream readUnsignedByte method. But then how to convert this value into double.
    int hdop = _data.readUnsignedByte();

    Hi,
    I have managed to read the first byte i.e hdop. I am getting the values of first 2 bytes properly. But the values where I have to read more than 1 byte is creating problem. Can anyone let me know whats wrong in the code?
    import java.io.DataInputStream;
    import java.io.FileInputStream;
    import java.util.Vector;
    public class SBPParser {
         //RandomAccessFile _file = null;
         FileInputStream _file = null;
         DataInputStream _data = null;
         int eofmark = 0;
         public SBPParser(FileInputStream f, DataInputStream d) {
              _file = f;
              _data = d;
         public void parseSBPFile() {
              try {
                        int hd = _data.readUnsignedByte();
                        double douhd = (hd & 0xff) * 0.2;
                        int svid = (_data.readUnsignedByte()) & 0xff;
                        int utcsec = _data.readUnsignedShort();
                        double utcs = (utcsec & 0xff) * 0.001;
                        int utc = Integer.parseInt(utcdatetime);
                        int sec = utc & 0xFC000000;
                        int min = utc & 0x3F00000;
                        int hour = utc & 0xF8000;
                        int day = utc & 0x7C00;
                        int months = utc & 0x3FF;*/
                        int utc = _data.readInt();
                        int sec = utc & 0xFC000000; //For fetching first 6 bits
                        int min = utc & 0x3F00000;  //For fetching next 6 bits
                        int hour = utc & 0xF8000;    //For fetching next 5 bits
                        int day = utc & 0x7C00;   //For fetching next 5 bits
                        int months = utc & 0x3FF; //For fetching next 10 bits
                        int svidlist = (_data.readInt()) & 0xff;
                        int lat = (_data.readInt()) & 0xff;
                        double latitude = lat * 0.0000001;
                        int lon =(_data.readInt()) & 0xff;
                        double longitude = lon * 0.0000001;
                        int alt = (_data.readInt()) & 0xff;
                        System.out.println("Value of Hdop ==> " + douhd);
                        System.out.println("Value of SVIDCnt ==> " + svid);
                        System.out.println("Value of UtcSec ==> " + utcs);
                        System.out.println("Value of seconds ==> " + sec);
                        System.out.println("Value of minutes ==> " + min);
                        System.out.println("Value of hours ==> " + hour);
                        System.out.println("Value of day ==> " + day);
                        System.out.println("Value of months ==> " + months);
                        System.out.println("Value of SVIDList ==> " + svidlist);
                        System.out.println("Value of Latiutude ==> " + latitude);
                        System.out.println("Value of Longitude ==> " + longitude);
                        System.out.println("Value of Altitude ==> " + alt);
                        //_data.skipBytes(31);
              } catch(Exception e) {
                   e.printStackTrace();
         public void print() {
              for(int i = 0; i < hdopVct.size(); i++) {
                   System.out.println("HDOP => " + hdopVct.elementAt(i));
              /*System.out.println("SVIDCNT => " + svidlistVct.elementAt(0));
              System.out.println("UTCSEC1 => " + utcsecVct.elementAt(0));
              System.out.println("UTCSEC2 => " + utcsecVct.elementAt(1));*/
         public static void main(String [] args) {
              try {
                   FileInputStream file_input = new FileInputStream("000000000_GPSLOG_20090605_122548.sbp");
                  DataInputStream data_in    = new DataInputStream (file_input);
                   SBPParser sbp = new SBPParser(file_input, data_in);
                   sbp.parseSBPFile();
                   //sbp.print();
              } catch(Exception e) {
                   e.printStackTrace();
    }Thanks & Regards
    Sunil

  • How to read binary files wrt specific BYTE size and length??

    Hello Everyone,
                                I have a project I want to accomplish. I have a binary file, and I would like to read the data and print on wfm in a specific order and size.
    The data is 16 bit binary type , and needs to be read in chunks of 2 bytes.
    i have 30 bytes of sample 1.
    followed by 2 bytes of sample 2.
    followed by another 2 bytes of sample 3.
    steps 2-4 should be repeated 10 times and then i should read sample 4 which is of 2 bytes.....
    How should I do it?? I don't have any VI build... all i have is the example VI...
    can anyone pleasehelp me???
    Now on LabVIEW 10.0 on Win7

    smercurio_fc, sorry for the confusion, i will try my best to explain...
    1. No, i don;t have to read the file again, once it has read, I used
    while loop just to see the data updating (i press run, and before i can
    visualize i have the waveforms; i can get rid of the while loop)
    2. I have 30 different values of 1 sample. actually, the data is cmg
    from tri-axial accelerometer; each axis is of 10 bytes(hence 3*10 =
    30bytes)
    3. I am repeating the steps 2-4 10 times because the data was written
    into the binary file after 10 times sampling the sensors(if first 3
    samples are read @ 1000hz, sample 4 was read at 1000/10 = 100hz)
    4. I am using the graphs to interpret the values, that's it. The
    values are already scaled when they were wrote to the binary file, I
    have to simply interpret it.
    I have made some changes in the VI, now i am reading only the first
    30bytes, that too, in chunks of 10-10-10 bytes, and plotting the 3
    samples simultaneously on a waveform chart. (will approach 1
    sensor/sample at a time) and running the loop for 10 times. I have changed I8 to I16 now.
    Please let me know if it makes sense to you now.
    P.S. each sample is a sensor data.
    Now on LabVIEW 10.0 on Win7
    Attachments:
    data_read.vi ‏24 KB

Maybe you are looking for