//cluser是hadoop集群,通过fs和集群文件系统交互
final DistributedFileSystem fs = cluster.getFileSystem();
// 要创建的文件名
final Path tmpFile1 = new Path("/tmpfile1.dat");
//创建文件
public static void createFile(FileSystem fs, Path fileName, long fileLen,
short replFactor, long seed) throws IOException {
if (!fs.mkdirs(fileName.getParent())) {
throw new IOException("Mkdirs failed to create " +
fileName.getParent().toString());
}
FSDataOutputStream out = null;
try {
out = fs.create(fileName, replFactor);
byte[] toWrite = new byte[1024];
Random rb = new Random(seed);
long bytesToWrite = fileLen;
while (bytesToWrite>0) {
rb.nextBytes(toWrite);