Java Reference
In-Depth Information
{
if (recno < 0 || recno >= numRecs())
throw new IllegalArgumentException(recno+" out of
range");
raf.seek(recno*RECLEN);
return read();
}
void update(int recno, String partnum, String partdesc,
int qty, int ucost)
throws IOException
{
if (recno < 0 || recno >= numRecs())
throw new IllegalArgumentException(recno+" out of
range");
raf.seek(recno*RECLEN);
write(partnum, partdesc, qty, ucost);
}
private Part read() throws IOException
{
StringBuffer sb = new StringBuffer();
for (int i = 0; i < PNUMLEN; i++)
sb.append(raf.readChar());
String partnum = sb.toString().trim();
sb.setLength(0);
for (int i = 0; i < DESCLEN; i++)
sb.append(raf.readChar());
String partdesc = sb.toString().trim();
int qty = raf.readInt();
int ucost = raf.readInt();
return new Part(partnum, partdesc, qty, ucost);
}
private void write(String partnum, String partdesc, int
qty, int ucost)
throws IOException
{
StringBuffer sb = new StringBuffer(partnum);
Search WWH ::




Custom Search