Java Hadoop分布式系统文件操作(二)

2014-11-23 21:36:30 · 作者: · 浏览: 57
tStream os = null;
Path f = new Path(ROOT_PATH + path);
os = fs.create(f,true);
os.writeBytes(string);

os.close();
fs.close();
return true;
}


public static void main(String[] args)
{
try {
DFSOperator.createFile("/lory/test1.txt", true);
DFSOperator.deleteFile("/dfs_operator.txt", true);
DFSOperator.writeStringToDFSFile("/lory/test1.txt", "You are a bad man.\nReally \n");
System.out.println(DFSOperator.readDFSFileToString("/lory/test1.txt"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("===end===");
}
}


--------------------------------------分割线 --------------------------------------


--------------------------------------分割线 --------------------------------------