本文整理汇总了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)
}
}
示例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)
}
}
示例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
}
}