Java Reference
In-Depth Information
import java.io.*;
import java.util.*;
public class FileResults
{
private static fi nal long REC_SIZE = 34;
private static fi nal int SURNAME_SIZE = 15;
private static String surname;
private static int mark;
public static void main(String[] args)
throws IOException
{
/*********************************************
*** SUPPLY CODE FOR main! ***
*********************************************/
}
public static void writeString(
RandomAccessFile fi le, String text,
int fi xedSize) throws IOException
{
int size = text.length();
if (size<=fi xedSize)
{
fi le.writeChars(text);
for (int i=size; i<fi xedSize; i++)
fi le.writeChar(' ');
}
else
fi le.writeChars(text.substring(
0,fi xedSize));
}
public static String readString(
RandomAccessFile fi le, int fi xedSize)
throws IOException
{
String value = "";
for (int i=0; i<fi xedSize; i++)
value+=fi le.readChar();
return value;
}
}
Search WWH ::




Custom Search