}
public void writeToFile(Path loc, JobConf job, Checksum crc)
throws IOException {
final FileSystem rfs = FileSystem.getLocal(job).getRaw();
CheckedOutputStream chk = null;
final FSDataOutputStream out = rfs.create(loc);
try {
if (crc != null) {
crc.reset();
chk = new CheckedOutputStream(out, crc);
chk.write(buf.array());
out.writeLong(chk.getChecksum().getValue());
} else {
out.write(buf.array());
}
} finally {
if (chk != null) {
chk.close();
} else {
out.close();
}
}
}