• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Scala FilenameFilter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: JunitResultParser

//设置package包名称以及导入依赖的类
package net.white_azalea.models.parsers.junits

import java.io.{ File, FilenameFilter }

import net.white_azalea.datas.junit.{ TestCase, TestFailure }
import net.white_azalea.models.parsers.utils.XML

import scala.xml.Node

class JunitResultParser {

  def parse(xmlDir: File): List[TestCase] = {
    val xmlFiles = xmlDir.listFiles(new FilenameFilter {
      override def accept(dir: File, name: String): Boolean =
        name.endsWith(".xml")
    })

    xmlFiles
      .flatMap(parseSingleFile)
      .toList
  }

  private[junits] def parseSingleFile(file: File): Seq[TestCase] = {
    (XML.load(file) \ "testcase").map(readTestCase)
  }

  private[junits] def readTestCase(node: Node): TestCase = {
    val methodName = node \@ "name"
    val className = node \@ "classname"
    val failures = (node \ "failure").map(readFailure)
    TestCase(methodName, className, failures)
  }

  private[junits] def readFailure(node: Node): TestFailure = {
    val message = node \@ "message"
    val typeMessage = node \@ "type"
    val cause = node.toString()
    TestFailure(message, typeMessage, cause)
  }
} 
开发者ID:Sunao-Yoshii,项目名称:JUnitDocMarge,代码行数:41,代码来源:JunitResultParser.scala


示例2: AttardiPlainTextExtractor

//设置package包名称以及导入依赖的类
package epam.idobrovolskiy.wikipedia.trending.preprocessing.attardi

import java.io.{File, FilenameFilter}

import epam.idobrovolskiy.wikipedia.trending.preprocessing.PlainTextExtractor


object AttardiPlainTextExtractor extends PlainTextExtractor {
  val AttardiLibPath = "./lib/attardi/wikiextractor/"

  private def getInFiles(inPath: String) = {
    val inDir = new File(inPath)
    if (inDir.isDirectory)
      inDir.listFiles(new FilenameFilter {
        def accept(dir: File, name: String) = name.endsWith(".bz2")
      })
    else
      Array(inDir)
  }

  private def cmdLine(inPath: String, outPath: String): String =
    s"python ${AttardiLibPath}WikiExtractor.py -o $outPath  --bytes 100M --processes 3 --links --sections --lists $inPath"

  private val SuffixRe = """.+xml\-(\w+)\.bz2""".r

//  val filesToSkip = Set("p10p30302")

  def extract(inPath: String, outPath: String): Unit = {
    val inFiles = getInFiles(inPath)

    import scala.sys.process._

    for (inFile <- inFiles) {
      val cInPath = inFile.getPath

      val (cOutPath: String, suffix: String) = cInPath match {
        case SuffixRe(suffix) => (outPath + "/" + suffix, suffix)
        case _ => outPath
      }

//      if(! filesToSkip.contains(suffix)) {
        val cCmdLine = cmdLine(cInPath, cOutPath)
        if (cCmdLine.! != 0)
          throw new RuntimeException(s"Plain text extraction failed for file: ${inFile.getAbsolutePath}")
//      }
    }
  }
} 
开发者ID:igor-dobrovolskiy-epam,项目名称:wikipedia-analysis-scala-core,代码行数:49,代码来源:AttardiPlainTextExtractor.scala


示例3: CsvLoader

//设置package包名称以及导入依赖的类
package com.miriamlaurel.aggro.csv.okcoin

import java.io.{File, FilenameFilter}
import java.time.{Instant, ZoneId}
import java.time.format.DateTimeFormatter
import java.time.temporal.TemporalAccessor
import java.util.UUID

import com.github.tototoshi.csv.CSVReader
import com.miriamlaurel.aggro.Inventory
import com.miriamlaurel.aggro.model.Fill
import com.miriamlaurel.fxcore._
import com.miriamlaurel.fxcore.asset.Currency
import com.miriamlaurel.fxcore.party.Party
import com.miriamlaurel.fxcore.portfolio.Position

object CsvLoader {

  val oft = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.of("Asia/Shanghai"))

  def parseCsv(tokens: Seq[String]): Fill = {
    val fillId = tokens.head.toLong
    val id = tokens(1).toLong
    val timeString: String = tokens(2)
    val btcBalance = SafeDouble(tokens(5).split("/")(0).replaceAll(",", "").toDouble)
    val cnyBalance = SafeDouble(tokens(7).replaceAll(",", "").toDouble)
    val parsedTime: TemporalAccessor = oft.parse(timeString)
    val ts = Instant.from(parsedTime)
    try {
      val btcStr = tokens(4).replaceAll(",", "")
      val btcS = if (btcStr.startsWith("+")) btcStr.substring(1) else btcStr
      val cnyStr = tokens(6).replaceAll(",", "")
      val cnyS = if (cnyStr.startsWith("+")) cnyStr.substring(1) else cnyStr
      val btc: Monetary = Monetary(SafeDouble(btcS.toDouble), Bitcoin)
      val cny: Monetary = Monetary(SafeDouble(cnyS.toDouble), Currency("CNY"))
      val position = Position(btc, cny, None, ts.toEpochMilli, UUID.randomUUID())
      val inventory: Inventory = Map(Bitcoin -> btcBalance, Currency("CNY") -> cnyBalance)
      Fill(Party("OKCN"), position, id.toString, Some(fillId.toString), Some(inventory))
    } catch {
      case x: Throwable =>
        x.printStackTrace()
        throw x
    }

  }

  def loadFromCsv(dir: File): Array[Fill] = {
    val files = dir.listFiles(new FilenameFilter {
      override def accept(dir: File, name: String): Boolean = name.endsWith(".csv")
    })
    val data = for (file <- files) yield {
      val reader = CSVReader.open(file)
      val fills = reader.toStream.drop(1).filter(line => {
        !line.head.startsWith("1024548491")
      }).map(parseCsv).toArray
      reader.close()
      fills
    }
    data.flatten
  }
} 
开发者ID:atemerev,项目名称:aggro,代码行数:62,代码来源:CsvLoader.scala


示例4: build

//设置package包名称以及导入依赖的类
package colonlc.mpm.tasks

import java.io.{File, FileWriter, FilenameFilter}

import colonlc.mcl.Compiler
import colonlc.mpm.Task

import scala.io.Source


private[mpm] object build extends Task {
	override def exec(args: Array[String]): Unit = {
		//throw new NotImplementedError("Task 'build' is not implemented yet!")
		val src = new File("src")
		assert(src.exists() && src.canRead)
		val funcs = (for(f <- src.listFiles(new FilenameFilter {	override def accept(dir: File, name: String): Boolean = name.matches(".mcl$")	}))
			yield Compiler.compile(Source.fromFile(f).mkString)
			).toList.flatten
		funcs.foreach(fun => new FileWriter(s"./compiled/${fun.name}.mcfunction").write(fun.body))
	}
} 
开发者ID:colonlc,项目名称:mcl,代码行数:22,代码来源:build.scala


示例5: FilePathManager

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

import java.io.{File, FilenameFilter}
import java.nio.file.Paths
import java.text.SimpleDateFormat
import java.util.Calendar


class FilePathManager(rootDir: String) {
  private var curDate: String = FilePathManager.CATALOGUE_GENERATOR()
  private val rootPath: File = new File(rootDir)
  private var nextID: Int = -1
  private val datFilter = new FilenameFilter() {
    override def accept(dir: File, name: String): Boolean = {
      name.toLowerCase().endsWith(FilePathManager.EXTENSION)
    }
  }

  if(!rootPath.isDirectory())
    throw new IllegalArgumentException(s"Path $rootDir doesn't exists.")

  def getCurrentPath(): String = Paths.get(rootDir, curDate, nextID.toString).toString

  def getNextPath(): String = {
    val testDate: String = FilePathManager.CATALOGUE_GENERATOR()

    if(curDate != testDate) {
      nextID = -1
      curDate = testDate
    } else {
      if(nextID >= 0) {
        nextID += 1
        val nextPath = Paths.get(rootDir, testDate, nextID.toString).toString
        return nextPath
      }
    }

    if(createPath()) {
      nextID = 0
      return Paths.get(rootDir, testDate, nextID.toString).toString
    } else {
      val filesDir = new File(Paths.get(rootDir, testDate).toString)
      var max = -1

      filesDir.listFiles(datFilter).foreach(f => {
        if (Integer.parseInt(f.getName.split("\\.")(0)) > max) max = Integer.parseInt(f.getName.split("\\.")(0))
      })
      nextID = max + 1
      return Paths.get(rootDir, testDate, nextID.toString).toString
    }
  }

  private def createPath(): Boolean = {
    val path = new File(Paths.get(rootDir, curDate).toString)
    if(!(path.exists() && path.isDirectory())) {
      path.mkdirs()
      true
    } else
      false
  }
} 
开发者ID:bwsw,项目名称:journaled-commit-log,代码行数:62,代码来源:FilePathManager.scala


示例6: Fuser

//设置package包名称以及导入依赖的类
package org.symnet.auxiliary

import java.io.{File, FilenameFilter, PrintStream}

import scala.io.Source

object Fuser {

  val seflTemplate =
    """
      |package org.change.v2.runners.sefl
      |
      |import org.change.v2.analysis.expression.concrete.nonprimitive._
      |import org.change.v2.analysis.expression.concrete.{ConstantValue, SymbolicValue}
      |import org.change.v2.analysis.processingmodels.Instruction
      |import org.change.v2.analysis.processingmodels.instructions._
      |
      |
      |object SEFLCodeAndLinks {
      |
      |  val i: Map[String, Instruction] = Map(
      |    _code_
      |  )
      |
      |  val l: Map[String, String] = Map(
      |    _links_
      |  )
      |
      |}
      |
    """.stripMargin

  def main(args: Array[String]): Unit = {
    val seflsFolder = new File("src/main/resources/sefls")
    val linksFolder = seflsFolder

    val seflCode = seflsFolder.listFiles(new FilenameFilter {
      override def accept(dir: File, name: String): Boolean = name.endsWith(".sefl")
    }).map(Source.fromFile(_).mkString).mkString(",\n")

    val linksCode = linksFolder.listFiles(new FilenameFilter {
      override def accept(dir: File, name: String): Boolean = name.endsWith(".links")
    }).map(Source.fromFile(_).mkString).mkString(",\n")

    new PrintStream(new File("SEFLCodeAndLinks.scala")).print(
      seflTemplate.replace("_code_", seflCode).replace("_links_", linksCode))
  }
} 
开发者ID:radustoenescu,项目名称:sefl-fuser,代码行数:49,代码来源:Fuser.scala


示例7: ExamplesTest

//设置package包名称以及导入依赖的类
package io.buoyant.namerd.examples

import io.buoyant.namerd.NamerdConfig
import java.io.{File, FilenameFilter}
import org.scalatest.FunSuite
import scala.io.Source

class ExamplesTest extends FunSuite {

  val examplesDir = new File("namerd/examples")
  val files = examplesDir.listFiles(new FilenameFilter {
    override def accept(dir: File, name: String): Boolean = name.endsWith(".yaml")
  })

  for (file <- files) {
    test(file.getName) {
      val source = Source.fromFile(file)
      try {
        val lines = source.getLines().toSeq
        val firstLine = lines.headOption
        if (!firstLine.contains("#notest")) {
          val config = lines.mkString("\n")
          val _ = NamerdConfig.loadNamerd(config)
        }
      } finally {
        source.close()
      }
    }
  }
} 
开发者ID:linkerd,项目名称:linkerd,代码行数:31,代码来源:ExamplesTest.scala


示例8: ExamplesTest

//设置package包名称以及导入依赖的类
package io.buoyant.linkerd
package examples

import io.buoyant.config.Parser
import java.io.{FilenameFilter, File}
import org.scalatest.FunSuite
import scala.io.Source

class ExamplesTest extends FunSuite {

  val examplesDir = new File("linkerd/examples")
  val files = examplesDir.listFiles(new FilenameFilter {
    override def accept(dir: File, name: String): Boolean = name.endsWith(".yaml")
  })

  val mapper = Parser.jsonObjectMapper(Linker.LoadedInitializers.iter)

  for (file <- files) {
    test(file.getName) {
      val source = Source.fromFile(file)
      try {
        val lines = source.getLines().toSeq
        val firstLine = lines.headOption
        if (!firstLine.contains("#notest")) {
          val yaml = lines.mkString("\n")
          val parsed = Linker.parse(yaml)
          val loaded = parsed.mk()
          assert(mapper.writeValueAsString(parsed).nonEmpty)
        }
      } finally source.close()
    }
  }
} 
开发者ID:linkerd,项目名称:linkerd,代码行数:34,代码来源:ExamplesTest.scala



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Scala breakOut类代码示例发布时间:2022-05-23
下一篇:
Scala HttpServletResponse类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap