NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
jon80
Joined: 05 May 2011 Posts: 29 Location: Malta
|
Posted: Sat Sep 10, 2011 8:43 am Post subject: Browsing serially through a CSV file... |
|
|
I am trying to create code that enables the user to browse serially through a CSV file, however, the following doesn't work, any idea why?
| Code: |
public void //<editor-fold defaultstate="collapsed" desc="Opens content from the catalogue file">
openCatalogue (int skipRecords)
//</editor-fold>
throws IOException
{
int fieldNumber = 1 + skipRecords;
while ((fieldNumber + skipRecords > 0) &&
(fieldNumber <= FIELDS_PER_RECORD) &&
(aRecord.readFields(CURRENT_CATALOG_FILE, FIELD_DELIMITER) != null))
{
if (fieldNumber == (1 + skipRecords))
{
txtLocation.setText(aRecord.readFields(CURRENT_CATALOG_FILE, FIELD_DELIMITER).get(fieldNumber - 1));
}
else if (fieldNumber == 2 + skipRecords)
{
txtTitle.setText(aRecord.readFields(CURRENT_CATALOG_FILE, FIELD_DELIMITER).get(fieldNumber - 1));
}
else if (fieldNumber == 3 + skipRecords)
{
txtAuthor.setText((aRecord.readFields(CURRENT_CATALOG_FILE, FIELD_DELIMITER).get(fieldNumber - 1)));
}
else if (fieldNumber == 4 + skipRecords)
{
txtPublisher.setText((aRecord.readFields(CURRENT_CATALOG_FILE, FIELD_DELIMITER).get(fieldNumber - 1)));
}
else if (fieldNumber == 5 + skipRecords)
{
Integer musicType = Integer.parseInt(((aRecord.readFields(CURRENT_CATALOG_FILE, FIELD_DELIMITER).get(fieldNumber - 1))));
int musicTypeAsPrimitive = musicType.intValue();
cboMusicType.setSelectedIndex(musicTypeAsPrimitive);
}
else if (fieldNumber == 6 + skipRecords)
{
final short SECONDS_TO_MINUTES = 60;
Integer lengthInSeconds = Integer.parseInt(aRecord.readFields(CURRENT_CATALOG_FILE, FIELD_DELIMITER).get(fieldNumber - 1));
txtLengthInMins.setText("" + (lengthInSeconds / SECONDS_TO_MINUTES));
txtLengthInSeconds.setText("" + (lengthInSeconds % SECONDS_TO_MINUTES));
}
++fieldNumber;
} //end while
}
...
private void btnPreviousActionPerformed(java.awt.event.ActionEvent evt) {
try
{
this.openCatalogue(FIELDS_PER_RECORD * -1);
}
catch (IOException e)
{
System.out.println("DEBUG" + e.getMessage());
}
}
private void btnNextActionPerformed(java.awt.event.ActionEvent evt) {
try
{
this.openCatalogue(FIELDS_PER_RECORD);
}
catch (IOException e)
{
System.out.println("DEBUG" + e.getMessage());
}
}
|
| Description: |
|
 Download |
| Filename: |
MusicCollection.rar |
| Filesize: |
543.92 KB |
| Downloaded: |
49 Time(s) |
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|