title: Read file into Buffer Chunks of 32 bytes
body: <p>I have a requirement to do the following after opening a txt file using JFileChooser</p>
  
  <ul>
  <li>Buffer chunks of 32 bytes; each row saves id (in column 1, succession number starting from 1) and the 32 bytes. The buffer size of the last row may be less than 32 byes, in which case pad it with ‘*’.</li>
  <li>Display the content of the buffer.</li>
  </ul>
  
  <p>Could anyone guide on the understanding of the requirement?. I have implemented the code t read the characters from file but not sure if i'm close to the requirements.</p>
  
  <pre><code>public void actionPerformed(ActionEvent e) {
  
      //Handle open button action.
      if (e.getSource() == openButton) {
          int returnVal = fc.showOpenDialog(JFileChooserDemo.this);
  
          if (returnVal == JFileChooser.APPROVE_OPTION) {
  
              File file = fc.getSelectedFile();
              BufferedReader reader = null;
              try {
                  reader = new BufferedReader(new FileReader(file));
              } catch (FileNotFoundException e2) {
                  // TODO Auto-generated catch block
                  e2.printStackTrace();
              }
              char[] buf = new char[32];
              int numRead = 0;
              int index = 1;
              try {
                  while ((numRead = reader.read(buf)) != -1) {
                      System.out.println(numRead);
                      String readData = String.valueOf(buf, 0, numRead);
                      if (numRead == 32) {
                          fileData.append(" " + index + " " + readData);
                          index++;
                      } else {
                          fileData.append(" * " + readData);
                          index = 0;
                      }
                      buf = new char[32];
                  }
              } catch (IOException e1) {
                  // TODO Auto-generated catch block
                  e1.printStackTrace();
              }
  
              try {
                  reader.close();
              } catch (IOException e1) {
                  // TODO Auto-generated catch block
                  e1.printStackTrace();
              }
  
              System.out.println(fileData);
          }
      }
  
      //Handle save button action.
  }
  </code></pre>