当前位置: 首页>>代码示例>>Java>>正文


Java FileListing类代码示例

本文整理汇总了Java中com.cloudera.sqoop.util.FileListing的典型用法代码示例。如果您正苦于以下问题:Java FileListing类的具体用法?Java FileListing怎么用?Java FileListing使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FileListing类属于com.cloudera.sqoop.util包,在下文中一共展示了FileListing类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addClassFilesFromDir

import com.cloudera.sqoop.util.FileListing; //导入依赖的package包/类
/**
 * Searches through a directory and its children for .class
 * files to add to a jar.
 *
 * @param dir - The root directory to scan with this algorithm.
 * @param jstream - The JarOutputStream to write .class files to.
 */
private void addClassFilesFromDir(File dir, JarOutputStream jstream)
    throws IOException {
  LOG.debug("Scanning for .class files in directory: " + dir);
  List<File> dirEntries = FileListing.getFileListing(dir);
  String baseDirName = dir.getAbsolutePath();
  if (!baseDirName.endsWith(File.separator)) {
    baseDirName = baseDirName + File.separator;
  }

  // For each input class file, create a zipfile entry for it,
  // read the file into a buffer, and write it to the jar file.
  for (File entry : dirEntries) {
    if (!entry.isDirectory()) {
      // Chomp off the portion of the full path that is shared
      // with the base directory where class files were put;
      // we only record the subdir parts in the zip entry.
      String fullPath = entry.getAbsolutePath();
      String chompedPath = fullPath.substring(baseDirName.length());

      boolean include = chompedPath.endsWith(".class")
          && sources.contains(
          chompedPath.substring(0, chompedPath.length() - ".class".length())
          + ".java");

      if (include) {
        // include this file.
        LOG.debug("Got classfile: " + entry.getPath() + " -> " + chompedPath);
        ZipEntry ze = new ZipEntry(chompedPath);
        jstream.putNextEntry(ze);
        copyFileToStream(entry, jstream);
        jstream.closeEntry();
      }
    }
  }
}
 
开发者ID:infinidb,项目名称:sqoop,代码行数:43,代码来源:CompilationManager.java

示例2: addClassFilesFromDir

import com.cloudera.sqoop.util.FileListing; //导入依赖的package包/类
/**
 * Searches through a directory and its children for .class
 * files to add to a jar.
 *
 * @param dir - The root directory to scan with this algorithm.
 * @param jstream - The JarOutputStream to write .class files to.
 */
private void addClassFilesFromDir(File dir, JarOutputStream jstream)
    throws IOException {
  LOG.debug("Scanning for .class files in directory: " + dir);
  List<File> dirEntries = FileListing.getFileListing(dir);
  String baseDirName = dir.getAbsolutePath();
  if (!baseDirName.endsWith(File.separator)) {
    baseDirName = baseDirName + File.separator;
  }

  // For each input class file, create a zipfile entry for it,
  // read the file into a buffer, and write it to the jar file.
  for (File entry : dirEntries) {
    if (!entry.isDirectory()) {
      // Chomp off the portion of the full path that is shared
      // with the base directory where class files were put;
      // we only record the subdir parts in the zip entry.
      String fullPath = entry.getAbsolutePath();
      String chompedPath = fullPath.substring(baseDirName.length());

      boolean include = chompedPath.endsWith(".class")
          && sources.contains(
          chompedPath.substring(0, chompedPath.length() - ".class".length())
          + ".java");

      if (include) {
        // include this file.
        if (Shell.WINDOWS) {
          // In Windows OS, elements in jar files still need to have a path
          // separator of '/' rather than the default File.separator which is '\'
          chompedPath = chompedPath.replace(File.separator, "/");
        }
        LOG.debug("Got classfile: " + entry.getPath() + " -> " + chompedPath);
        ZipEntry ze = new ZipEntry(chompedPath);
        jstream.putNextEntry(ze);
        copyFileToStream(entry, jstream);
        jstream.closeEntry();
      }
    }
  }
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:48,代码来源:CompilationManager.java


注:本文中的com.cloudera.sqoop.util.FileListing类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。