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


Scala FileUtil类代码示例

本文整理汇总了Scala中org.apache.hadoop.fs.FileUtil的典型用法代码示例。如果您正苦于以下问题:Scala FileUtil类的具体用法?Scala FileUtil怎么用?Scala FileUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: globPath

//设置package包名称以及导入依赖的类
package com.paypal.risk.madmen20.util

import java.io.{OutputStreamWriter, BufferedReader, InputStreamReader}

import org.apache.hadoop.fs.{FileUtil, FileSystem, Path}
import org.apache.spark.SparkContext


  def globPath(path: String)(implicit sc: SparkContext): Seq[String] = {
    val conf = sc.hadoopConfiguration
    val glob = new Path(path)
    val fileSystem = FileSystem.get(conf)
    val allStatus = fileSystem.globStatus(glob)
    val allPath = FileUtil.stat2Paths(allStatus)
    allPath.map(_.toString)
  }

  def deleteFolder(path: String)(implicit sc: SparkContext): Boolean = {
    val conf = sc.hadoopConfiguration
    val fileSystem = FileSystem.get(conf)
    fileSystem.delete(new Path(path), true)
  }
} 
开发者ID:yanlzhang8936,项目名称:madmen20,代码行数:24,代码来源:HdfsUtil.scala

示例2: globPath

//设置package包名称以及导入依赖的类
package com.paypal.risk.smunf.util

import java.io.{OutputStreamWriter, BufferedReader, InputStreamReader}

import org.apache.hadoop.fs.{FileUtil, FileSystem, Path}
import org.apache.spark.SparkContext

import scala.language.reflectiveCalls


  def globPath(path: String)(implicit sc: SparkContext): Seq[String] = {
    val conf = sc.hadoopConfiguration
    val glob = new Path(path)
    val fileSystem = FileSystem.get(conf)
    val allStatus = fileSystem.globStatus(glob)
    val allPath = FileUtil.stat2Paths(allStatus)
    allPath.map(_.toString)
  }

  def delete(path: String)(implicit sc: SparkContext): Boolean = {
    val conf = sc.hadoopConfiguration
    val fileSystem = FileSystem.get(conf)
    fileSystem.delete(new Path(path), true)
  }
} 
开发者ID:yanlzhang8936,项目名称:Smunf,代码行数:26,代码来源:HdfsIOUtil.scala

示例3: HDFSUtils

//设置package包名称以及导入依赖的类
package com.iwantfind

import org.apache.hadoop.conf.Configuration
import org.apache.hadoop.fs.{FileUtil, Path, FileSystem}





class HDFSUtils(conf: Configuration) {
  val fileSystem = FileSystem.get(conf)

  def ls(path:String)=
  {
    println("list path:"+path)
    val fs = fileSystem.listStatus(new Path(path))
    val listPath = FileUtil.stat2Paths(fs)
    for( p <- listPath)
    {
      println(p)
    }
    println("----------------------------------------")
  }

  def du(xpath: String) : Long = {
    var size : Long = 0
    val path = new Path(xpath)
    if (fileSystem.exists(path)) {
      var dir = fileSystem.getContentSummary(path)
      dir.getLength
    }

    size
  }
} 
开发者ID:Yiran-wu,项目名称:iwantfind-tool,代码行数:36,代码来源:HDFSUtils.scala


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