Java Reference
In-Depth Information
new RandomAccessFile(“scores.html”, “rw”);
for(int i = 1; i <= 6; i++)
{
System.out.println(file.readLine());
}
long current = file.getFilePointer();
file.seek(current + 6);
file.write(“34”.getBytes());
for(int i = 1; i <= 5; i++)
{
System.out.println(file.readLine());
}
current = file.getFilePointer();
file.seek(current + 6);
file.write(“27”.getBytes());
file.close();
}catch(IOException e)
{
e.printStackTrace();
}
}
}
Figure 16.6
Scores.html file after running the RandomAccessDemo program.
Search WWH ::




Custom Search