title: Reading Entries from ASCII file into JAVA(The first entry is what determines record length as well as total number of records)
body: <p>Making use of an ASCII .DAT file that contains multiple records of a fixed length I would like to read each record and generate an output based on its certain portions of its contents.</p>
  
  <p>So far my program does exactly this but I was alerted to the fact that the first field in each .DAT file starts with the record length and number of records, the only issue I am having is reading this first field and extracting the data as usable, the issue is that the data is in ASCII chars and not decimal numbers.</p>
  
  <p>Below is a code snipet in BASIC that reads the same file and extracts the initial data required</p>
  
  <pre><code>    CLS
      INPUT "Survey System Data File? : ", survey$
      survey$ = "f:\apps\survey\" + survey$
      reclen = 3004
      OPEN survey$ + ".dat" FOR RANDOM AS 1 LEN = reclen
      FIELD #1, 3 AS RL$, 9 AS n$
      GET #1, 1
      RL = CVI(RL$): n = CVI(n$)
      PRINT "Record Length     = "; RL
      reclen = RL
      PRINT "Number of Records = "; n
      CLOSE #1
  </code></pre>
  
  <p>Is there a way of doing something similar in Java?</p>
  
  <p>The initial record and second record are seen below. The second record starts from 0001511</p>
  
  <p>#Å            Õ                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            000151115 2                      351228 6 8131720                                                    1121211  12111121121111111112112111                 Treat people fairly. Motivated people who go the extra mile should be recognised. Trust employees to make decisions and find out what is best for the business. Examine the workload and the performance and timing of the work.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        11 6 5 6 5                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                2003/10/007:12 21    111                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            2 1154 1 1 113 1   1   1   1   1                                                                          4000100  0  0  0   400     0     0     0   400     4100.0000.0000.0     0    0   10   24                                                                        12111none                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 9    1346  </p>
  
  <p>As you can see the initial characters are ASCII chars and not decimals that I'm looking for.</p>
  
  <p>Many thanks in advance for the help.</p>