Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I am interpreting this format correctly you have a binary file format with fixed-length records. Some of these records are not character data (COBOL computational fields?)</p> <p>So, you will have to read the records using a more low-level approach processing individual fields of each record:</p> <pre><code>import java.io.*; public class Record { private byte[] kdgex = new byte[2]; // COMP private byte[] b1code = new byte[2]; // COMP private byte[] b1number = new byte[8]; // DISPLAY // other fields public void read(DataInput data) throws IOException { data.readFully(kdgex); data.readFully(b1code); data.readFully(b1number); // other fields } public void write(DataOutput out) throws IOException { out.write(kdgex); out.write(b1code); out.write(b1number); // other fields } } </code></pre> <p>Here I've used byte arrays for the first three fields of the record but you could use other more suitable types where appropriate (like a <code>short</code> for the first field with <a href="http://docs.oracle.com/javase/7/docs/api/java/io/DataInputStream.html#readShort%28%29" rel="nofollow">readShort</a>.) <em>Note: my interpretation of the field widths is likely wrong; it is just an example.</em></p> <p>The <a href="http://docs.oracle.com/javase/7/docs/api/java/io/DataInputStream.html" rel="nofollow">DataInputStream</a> is generally used as a <a href="http://docs.oracle.com/javase/7/docs/api/java/io/DataInput.html" rel="nofollow">DataInput</a> implementation.</p> <p>Since all characters in the source and target encodings use a one-octet-per code point you should be able to transcode the character data fields using a method like this:</p> <pre><code>public static byte[] transcodeField(byte[] source, Charset from, Charset to) { byte[] result = new String(source, from).getBytes(to); if (result.length != source.length) { throw new AssertionError(result.length + "!=" + source.length); } return result; } </code></pre> <p><em>I suggest tagging your question with COBOL (assuming that is the source of this format) so that someone else can speak with more authority on the format of the data source.</em></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload