Page 2 of 2 FirstFirst 12
Results 21 to 27 of 27
  1. #21
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,559
    Rep Power
    25

    Default Re: how to read flow file ?

    it's not txt file
    I know. The DataInputStream class methods read bytes and converts them into primitives like int or short etc

    When it can read the first four bytes and create an int from them.

  2. #22
    uniojnqoifazy is offline Member
    Join Date
    Dec 2011
    Posts
    13
    Rep Power
    0

    Default Re: how to read flow file ?

    hi norm,
    it's my code , but then how to read the first four bytes ?


    public static void Readbinary() throws Exception
    {


    String file = "D:\\05-09.190501+0800";

    DataInputStream dis = new DataInputStream(new FileInputStream(file));
    String line = null;
    byte b[] = new byte[4];
    dis.read(b);

    //how to read the first four byte as int?????

    }
    Last edited by uniojnqoifazy; 12-22-2011 at 02:56 AM.

  3. #23
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,559
    Rep Power
    25

    Default Re: how to read flow file ?

    how to read the first four byte as int?
    Use the readInt method.

  4. #24
    uniojnqoifazy is offline Member
    Join Date
    Dec 2011
    Posts
    13
    Rep Power
    0

    Default Re: how to read flow file ?

    hi norm,


    public static void Readbinary() throws Exception
    {


    String file = "D:\\05-09.190501+0800";

    DataInputStream dis = new DataInputStream(new FileInputStream(file));
    String line = null;
    byte b[] = new byte[4];
    dis.read(b);
    System.out.println(dis.readInt()); // are you mean this ?????
    System.out.println(dis.readUTF());
    }
    Last edited by uniojnqoifazy; 12-22-2011 at 02:56 AM.

  5. #25
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,559
    Rep Power
    25

    Default Re: how to read flow file ?

    What happens when you execute the code?

  6. #26
    uniojnqoifazy is offline Member
    Join Date
    Dec 2011
    Posts
    13
    Rep Power
    0

    Default Re: how to read flow file ?

    hi norm,
    error msg :


    1476395008 -->it's not what i want readable value ????
    java.io.UTFDataFormatException: malformed input around byte 12
    at java.io.DataInputStream.readUTF(Unknown Source)
    at java.io.DataInputStream.readUTF(Unknown Source)
    at ReadData.Readbinary(ReadData.java:24)
    at ReadData.main(ReadData.java:31)

  7. #27
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,559
    Rep Power
    25

    Default Re: how to read flow file ?

    What data is in the file at byte 12?
    Why are you using the readUTF method to read from the file?
    I thought from your record layout in post #18 that all of the data was numeric.
    You need to enhance the layout given in post#18 to explain what the data format is.
    Are any of the fields defined there NOT numeric values?

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 1
    Last Post: 08-05-2011, 09:21 PM
  2. How to generate Data Flow Diagram(Work Flow Diagram)
    By stsivaraj in forum AWT / Swing
    Replies: 1
    Last Post: 12-22-2010, 11:21 PM
  3. Replies: 2
    Last Post: 05-11-2009, 10:07 AM
  4. Replies: 0
    Last Post: 02-11-2009, 09:53 AM
  5. How to read a text file from a Java Archive File
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-08-2008, 09:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •