本文整理汇总了Scala中org.apache.commons.io.FilenameUtils类的典型用法代码示例。如果您正苦于以下问题:Scala FilenameUtils类的具体用法?Scala FilenameUtils怎么用?Scala FilenameUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FilenameUtils类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: fontPackage
//设置package包名称以及导入依赖的类
package com.karasiq.scalajsbundler.dsl
import java.net.URL
import com.karasiq.scalajsbundler.ScalaJSBundler.{PageContent, ResourceAsset}
import org.apache.commons.io.FilenameUtils
import org.scalajs.sbtplugin.JarJSModuleID
import sbt.Keys._
import sbt._
trait AssetShortcuts { self: BundlerDsl ?
def fontPackage(name: String, baseUrl: String, dir: String = "fonts", extensions: Seq[String] = Seq("eot", "svg", "ttf", "woff", "woff2")): Seq[PageContent] = {
extensions.map { ext ?
Static(s"$dir/$name.$ext") from new URL(s"$baseUrl.$ext")
}
}
implicit class GithubRepositoryOps(gh: GithubRepository) {
def fonts(name: String = "", dir: String = "fonts", extensions: Seq[String] = Seq("eot", "svg", "ttf", "woff", "woff2")): Seq[PageContent] = {
val fontName = Option(name).filter(_.nonEmpty).getOrElse(FilenameUtils.getBaseName(gh.path.last))
fontPackage(fontName, gh.url, dir, extensions)
}
}
implicit class WebJarOps(moduleId: JarJSModuleID) {
def fonts(name: String = "", dir: String = "fonts", extensions: Seq[String] = Seq("eot", "svg", "ttf", "woff", "woff2")): Seq[PageContent] = {
val fontName = Option(name).filter(_.nonEmpty).getOrElse(FilenameUtils.getBaseName(moduleId.jsDep.resourceName))
extensions.map { ext ?
Static(s"$dir/$fontName.$ext") from JarJSModuleID(moduleId.module, s"${moduleId.jsDep.resourceName}.$ext")
}
}
}
def github(user: String, repo: String, version: String): GithubRepository = {
GithubRepository(user, repo, version)
}
def resource(path: String): ResourceAsset = {
ResourceAsset(path)
}
def scalaJsApplication(project: Project, launcher: Boolean = true, fastOpt: Boolean = false): Def.Initialize[Seq[PageContent]] = {
(name in project, target in project, scalaVersion in project) {
case (name, target, version) ?
val output = target / s"scala-${CrossVersion.binaryScalaVersion(version)}"
val files = Seq(
if (fastOpt) Script from output / s"$name-fastopt.js"
else Script from output / s"$name-opt.js"
)
if (launcher) files :+ (Script from output / s"$name-launcher.js") else files
}
}
}
开发者ID:Karasiq,项目名称:sbt-scalajs-bundler,代码行数:55,代码来源:AssetShortcuts.scala
示例2: HanaExtensionComparator
//设置package包名称以及导入依赖的类
import java.io.File
import org.apache.commons.io.FilenameUtils
sealed class HanaExtensionComparator extends Ordering[File] {
private val activationPriorities = Map("xsapp" -> 1,
"xsprivileges" -> 2,
// isDirectory()) -> 3,
"hdbstructure" -> 4,
"hdbprocedure" -> 5,
"xsjslib" -> 6,
// default -> 7
"hdbrole" -> 8,
"xsaccess" -> 9)
override def compare(x: File, y: File): Int = {
def getActivationPriority(file: File): Int = {
if (file.isDirectory) return 3
val extension = FilenameUtils.getExtension(file.getName.toLowerCase)
return activationPriorities.getOrElse(extension, 7)
}
if (getActivationPriority(x) == getActivationPriority(y)) {
return x.compareTo(y)
}
return getActivationPriority(x) - getActivationPriority(y)
}
}
开发者ID:janosbinder,项目名称:hana-activator,代码行数:28,代码来源:HanaExtensionComparator.scala
示例3: FileInfo
//设置package包名称以及导入依赖的类
package strnet
import java.io.File
import scala.sys.process._
import scalafx.Includes._
import org.apache.commons.io.FilenameUtils
import scalafx.scene.control.Label
import scalafx.scene.image.{ Image, ImageView }
import scalafx.scene.input.MouseEvent
import scalafx.scene.layout.VBox
class FileInfo(
file: File,
command: String,
thumbnailExtension: String,
defaultImg: Image)
extends VBox {
val baseName = FilenameUtils.getBaseName(file.getName)
val imgFile = new File(FilenameUtils.removeExtension(file.getPath()) + thumbnailExtension)
val img = if ( imgFile.exists() ) {
new Image(imgFile.toURI().toString)
} else {
defaultImg
}
val imageView = new ImageView(img) {
preserveRatio = true
smooth = false
}
if (img.getWidth > 120) {
imageView.fitWidth = 120
}
if (img.getHeight > 120) {
imageView.fitHeight = 120
}
onMouseClicked = (e: MouseEvent) => new Thread() {
override def run() {
Seq(command, file.getPath).!
}
}.start()
styleClass.append("thumbnail")
children.addAll(
imageView,
new Label(baseName))
alignment = scalafx.geometry.Pos.TopCenter
}
开发者ID:hossshy,项目名称:bestiary,代码行数:51,代码来源:FileInfo.scala
示例4: ResultsWriter
//设置package包名称以及导入依赖的类
package com.eigenroute.portfoliosimulation.writer
import java.io.{File, FileOutputStream}
import akka.actor.ActorRef
import com.eigenroute.portfoliosimulation._
import com.eigenroute.portfoliosimulation.portfoliocalculation.PortfolioPerformance
import com.eigenroute.portfoliosimulation.util.WatchedActor
import org.apache.commons.io.FilenameUtils
import org.joda.time.format.DateTimeFormat
class ResultsWriter(reaper: ActorRef, file: File) extends WatchedActor(reaper) {
val filePath = file.getAbsolutePath
var portfolioPerformances: Seq[PortfolioPerformance] = Seq.empty
override def receive = {
case rebalancedPortfolio: RebalancedPortfolio =>
log.info(s"\n\n ResultsWriter: RebalancedPortfolio: ${rebalancedPortfolio.portfolioPerformance}")
val datePattern: String = "yyyy-MM-dd"
val startDate = rebalancedPortfolio.portfolioPerformance.investmentPeriod.startDate
val endDate = rebalancedPortfolio.portfolioPerformance.investmentPeriod.endDate
val dateTimeFormatter = DateTimeFormat.forPattern(datePattern)
val sheetName = dateTimeFormatter.print(startDate) + "_" + dateTimeFormatter.print(endDate)
val filePathWithoutExtension = FilenameUtils.removeExtension(filePath)
val extension = FilenameUtils.getExtension(filePath)
val finalFilePath = filePathWithoutExtension + "_" + sheetName + "." + extension
val writer = new PerformanceResultsWriter(finalFilePath, sheetName)
writer.writeWide(rebalancedPortfolio)
case portfolioPerformance: PortfolioPerformance =>
portfolioPerformances = portfolioPerformances :+ portfolioPerformance
case simulationParameters: SimulationParameters =>
log.info(s"\n\n ResultsWriter: Got a summary: ${simulationParameters.portfolioDesign}")
val summaryWorkbook =
new SummaryResultsRecorder(simulationParameters, portfolioPerformances.sortBy( performance =>
performance.investmentPeriod.startDate.getMillis)).write()
val fileOutputStream = new FileOutputStream(file)
summaryWorkbook.write(fileOutputStream)
fileOutputStream.close()
}
}
开发者ID:shafiquejamal,项目名称:portfolio-simulation,代码行数:48,代码来源:ResultsWriter.scala
示例5: SaveImageRequest
//设置package包名称以及导入依赖的类
package models
import java.net.URL
import java.nio.file.Paths
import org.apache.commons.io.FilenameUtils
import play.api.libs.json._
import play.api.libs.functional.syntax._
object SaveImageRequest {
implicit val saveImageRequestWrites: Writes[SaveImageRequest] = (
(JsPath \ "path").write[String] and
(JsPath \ "url").write[String]
)(unlift(SaveImageRequest.unapply))
def apply(imageUrl: URL, folderPath: String): SaveImageRequest = {
val imageName = FilenameUtils.getName(imageUrl.getPath)
val path = Paths.get(folderPath, imageName).toString
new SaveImageRequest(path, imageUrl.toString)
}
def unapply(arg: SaveImageRequest): Option[(String, String)] = Some((arg.path, arg.url))
}
class SaveImageRequest(val path: String, val url: String)
开发者ID:kezhu,项目名称:imagevoter,代码行数:26,代码来源:SaveImageRequest.scala
注:本文中的org.apache.commons.io.FilenameUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论