本文整理匯總了Java中org.apache.hadoop.fs.LocalFileSystem.mkdirs方法的典型用法代碼示例。如果您正苦於以下問題:Java LocalFileSystem.mkdirs方法的具體用法?Java LocalFileSystem.mkdirs怎麽用?Java LocalFileSystem.mkdirs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.hadoop.fs.LocalFileSystem
的用法示例。
在下文中一共展示了LocalFileSystem.mkdirs方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testLocalFs
import org.apache.hadoop.fs.LocalFileSystem; //導入方法依賴的package包/類
public static void testLocalFs() throws IOException {
LocalFileSystem fs = LocalFileSystem.getLocal(conf);
System.out.println(fs);
String testDir = "/home/winter/temp/temp";
String innerDir = "test";
FileStatus[] statusArray = fs.listStatus(new Path(testDir));
if (statusArray == null || statusArray.length == 0) {
Path innerDirPath = new Path(new Path(testDir), innerDir);
Path innerFilePath = new Path(new Path(testDir), "hdfs-site");
fs.mkdirs(innerDirPath);
fs.copyFromLocalFile(new Path("/home/winter/hdfs-site.xml"), innerFilePath);
fs.setReplication(innerFilePath, (short) 3);
}
for (FileStatus status : statusArray) {
if (status.isDir()) {
System.out.println("winter file is a dir: " + status.getPath());
} else {
System.out.println("winter file is a file: " + status.getPath().getName());
}
}
}
示例2: setUp
import org.apache.hadoop.fs.LocalFileSystem; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
LocalFileSystem fs = FileSystem.getLocal(conf);
if (fs.exists(TEST_ROOT) && !fs.delete(TEST_ROOT, true)) {
fail("Can't clean up test root dir");
}
fs.mkdirs(TEST_ROOT);
}
示例3: setup
import org.apache.hadoop.fs.LocalFileSystem; //導入方法依賴的package包/類
@Before
public void setup() throws Exception {
LocalFileSystem fs = FileSystem.getLocal(conf);
if (fs.exists(TEST_DIR) && !fs.delete(TEST_DIR, true)) {
Assert.fail("Can't clean up test root dir");
}
fs.mkdirs(TEST_DIR);
}
示例4: testCopyToLocal
import org.apache.hadoop.fs.LocalFileSystem; //導入方法依賴的package包/類
@Test
/*
* Tests copying from archive file system to a local file system
*/
public void testCopyToLocal() throws Exception {
final String fullHarPathStr = makeArchive();
// make path to copy the file to:
final String tmpDir
= System.getProperty("test.build.data","build/test/data") + "/work-dir/har-fs-tmp";
final Path tmpPath = new Path(tmpDir);
final LocalFileSystem localFs = FileSystem.getLocal(new Configuration());
localFs.delete(tmpPath, true);
localFs.mkdirs(tmpPath);
assertTrue(localFs.exists(tmpPath));
// Create fresh HarFs:
final HarFileSystem harFileSystem = new HarFileSystem(fs);
try {
final URI harUri = new URI(fullHarPathStr);
harFileSystem.initialize(harUri, fs.getConf());
final Path sourcePath = new Path(fullHarPathStr + Path.SEPARATOR + "a");
final Path targetPath = new Path(tmpPath, "straus");
// copy the Har file to a local file system:
harFileSystem.copyToLocalFile(false, sourcePath, targetPath);
FileStatus straus = localFs.getFileStatus(targetPath);
// the file should contain just 1 character:
assertEquals(1, straus.getLen());
} finally {
harFileSystem.close();
localFs.delete(tmpPath, true);
}
}
示例5: setUp
import org.apache.hadoop.fs.LocalFileSystem; //導入方法依賴的package包/類
@Override
public void setUp() throws Exception {
LocalFileSystem fs = FileSystem.getLocal(conf);
if (fs.exists(TEST_ROOT) && !fs.delete(TEST_ROOT, true)) {
Assert.fail("Can't clean up test root dir");
}
fs.mkdirs(TEST_ROOT);
}