當前位置: 首頁>>代碼示例>>Java>>正文


Java LocalFileSystem.mkdirs方法代碼示例

本文整理匯總了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());
    }
  }
}
 
開發者ID:fengchen8086,項目名稱:LCIndex-HBase-0.94.16,代碼行數:22,代碼來源:TestLocalFS.java

示例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);
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:9,代碼來源:TestBloomMapFile.java

示例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);
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:9,代碼來源:TestMapFile.java

示例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);      
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:35,代碼來源:TestHadoopArchives.java

示例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);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:9,代碼來源:TestBloomMapFile.java


注:本文中的org.apache.hadoop.fs.LocalFileSystem.mkdirs方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。