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

Scala Writer类代码示例

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

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



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

示例1: ChannelHelper

//设置package包名称以及导入依赖的类
package us.illyohs.sinked.helper

import java.io.{File, FileWriter, IOException, Writer}
import java.util

import com.google.gson.{FieldNamingPolicy, Gson, GsonBuilder}
import org.spongepowered.api.Sponge
import us.illyohs.sinked.Sinked
import us.illyohs.sinked.channel.Channel

object ChannelHelper {

  val chanList:util.List[Channel] = new  util.ArrayList[Channel]()

  val sinked:Sinked = null
  val channelPath = "./channels/"

  val channelDir = new File(channelPath)

  def initChannel: Unit = {
    chanList.add(new GlobalChannel)
    chanList.add(new LocalChannel)
    if (!channelDir.exists()) {
      //      sinked.getLogger.warn("Channel directory not found!")
      //      sinked.getLogger.info("Now creating channel directory")

      channelDir.mkdir()
      val gson: Gson = new GsonBuilder()
        .setPrettyPrinting()
        .serializeNulls()
        .setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE)
        .create()
      for (i <- 0 to 1) {
        val ch = chanList.get(i)
        val json = gson.toJson(ch)
        val w: Writer = new FileWriter(channelPath + ch.getName + ".json")
        try {
          w.write(json)
          w.close()
          //          sinked.getLogger.info("Created default channel: " +ch.getName)
        } catch {
          case e: IOException => e.printStackTrace()
        }
      }
      //      createDefualtjons
    }
  }


  case class GlobalChannel() extends Channel("Global", "", "G", "", "", false, true, false, false, true)
  case class LocalChannel() extends Channel("Local", "", "L", "", "", false, true, false, false, false)
} 
开发者ID:DragonTechMC,项目名称:Sinked,代码行数:53,代码来源:ChannelHelper.scala


示例2: Csv

//设置package包名称以及导入依赖的类
package controllers

  import java.io.{StringWriter, Writer}

  import com.github.tototoshi.csv.CSVWriter
  import org.intracer.wmua.{ImageWithRating, Round, User}

  object Csv {

    def writeStringBuffer(data: Seq[Seq[Any]]): StringBuffer = {
      val writer = new StringWriter()
      write(data, writer)
      writer.getBuffer
    }

    def writeRow(data: Seq[Any]): String = {
      val writer = new StringWriter()
      val csv = CSVWriter.open(writer)
      csv.writeRow(data)
      csv.close()
      writer.getBuffer.toString
    }

    def write(data: Seq[Seq[Any]], writer: Writer): Unit = {
      val csv = CSVWriter.open(writer)
      csv.writeAll(data)
      csv.close()
    }

    def exportRates(files: Seq[ImageWithRating], jurors: Seq[User], round: Round): Seq[Seq[String]] = {
      val header = Seq("Rank", "File", "Overall") ++ jurors.map(_.fullname)

      val ranks = ImageWithRating.rankImages(files, round)
      val rows = for ((file, rank) <- files.zip(ranks))
        yield Seq(rank, file.image.title, file.rateString(round)) ++ jurors.map(file.jurorRateStr)

      header +: rows
    }

    def addBom(data: Seq[Seq[String]]): Seq[Seq[String]] = {
      val BOM = "\ufeff"
      val header = data.head
      val headerWithBom = (BOM + header.head) +: header.tail
      headerWithBom +: data.tail
    }
  } 
开发者ID:intracer,项目名称:wlxjury,代码行数:47,代码来源:Csv.scala


示例3: Config

//设置package包名称以及导入依赖的类
package pl.mojepanstwo.sap.toakoma

import java.io.{FileWriter, Writer}

import com.github.tototoshi.csv._

import scala.reflect.runtime.{universe => ru}
import scala.io.Source

case class Config(header: String = "#",
                  delimiter: Char = defaultCSVFormat.delimiter,
                  quoteChar: Char = defaultCSVFormat.quoteChar,
                  treatEmptyLineAsNil: Boolean = defaultCSVFormat.treatEmptyLineAsNil,
                  escapeChar: Char = defaultCSVFormat.escapeChar,
                  lineTerminator: String = defaultCSVFormat.lineTerminator,
                  quoting: Quoting = defaultCSVFormat.quoting) extends CSVFormat

object ObjectCSV {
  def apply(config: Config = new Config()) = new ObjectCSV(config)
}

protected class ObjectCSV(config: Config) {

  def readCSV[T: ru.TypeTag](resPath: String): IndexedSeq[T] = {
    val objectConverter = new ObjectConverter
    val csvReader = CSVReader.open(Source.fromResource(resPath))(config)
    val data = csvReader.all()
    val header = data.head
    if (!header.head.startsWith(config.header)) {
      throw new Exception("Expected a commented out header. Found: " + header)
    }
    val headerWithoutComments = Array(header.head.substring(1)) ++ header.tail
    val objects = data.view.tail.map(row => objectConverter.toObject[T](row, headerWithoutComments))
    objects.toVector
  }
} 
开发者ID:PrawoPolskie,项目名称:toakoma,代码行数:37,代码来源:ObjectCSV.scala


示例4: apply

//设置package包名称以及导入依赖的类
package com.github.madoc.create_sbt_project.io

import java.io.Writer

import com.github.madoc.create_sbt_project.io.Write.{StringEscapedWrite, WithLineSeparatedByDoubleLineBreaksWrite}

trait Write {
  def apply(str:String):Write
  def apply(ch:Char):Write = apply(ch toString)
  def apply[A](the:A)(implicit output:Output[A]):Write = {output(the)(this); this}
  def line(str:String):Write = apply(str).lineBreak()
  def lineBreak():Write = apply('\n')

  def inQuotes[U](f:Write?U):Write = {apply('"'); f(this); apply('"')}
  def stringEscaped:Write = new StringEscapedWrite(this)
  def withLinesSeparatedByDoubleLineBreaks:Write = new WithLineSeparatedByDoubleLineBreaksWrite(this)

  def asJavaIOWriter:Writer = {
    val self = this
    new Writer() {
      def write(cbuf:Array[Char], off:Int, len:Int) {self(new String(cbuf, off, len))}
      def flush() {}
      def close() {}
    }
  }
}
object Write {
  class WriteToAppendable(appendable:Appendable) extends Write {
    def apply(str:String) = {appendable append str; this}
    override def apply(ch:Char) = {appendable append ch; this}
  }

  class StringEscapedWrite(writeUnescaped:Write) extends Write {
    def apply(str:String) = {str foreach apply; this}
    override def apply(ch:Char) = {ch match {
      case '\n' ? writeUnescaped("\\n"); case '\r' ? writeUnescaped("\\r"); case '\t' ? writeUnescaped("\\t")
      case '\\' ? writeUnescaped("\\\\"); case '"' ? writeUnescaped("\\\""); case _ ? writeUnescaped(ch)
    }; this}
  }

  class WithLineSeparatedByDoubleLineBreaksWrite(writeNormal:Write) extends Write {
    private var isRightAfterLineBreak = false
    def apply(str:String) = {str foreach apply; this}
    override def apply(ch:Char) =
      if(ch=='\n') {isRightAfterLineBreak=true; writeNormal(ch); this}
      else {
        if(isRightAfterLineBreak) {writeNormal('\n'); isRightAfterLineBreak=false}
        writeNormal(ch); this
      }
  }
} 
开发者ID:Madoc,项目名称:create-sbt-project,代码行数:52,代码来源:Write.scala


示例5: Using

//设置package包名称以及导入依赖的类
import java.io.Writer

import scala.io.Source

object Using {
  def apply[A, B](resource: A)(process: A => B)(implicit closer: Closer[A]): B =
    try {
      process(resource)
    } finally {
      closer.close(resource)
    }
}

case class Closer[-A](close: A => Unit)

object Closer {
  implicit val sourceCloser: Closer[Source] = Closer(_.close())
  implicit val writerCloser: Closer[Writer] = Closer(_.close())
} 
开发者ID:piyo7,项目名称:scala-min.g8,代码行数:20,代码来源:Using.scala


示例6: withWriter

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

import java.io.{BufferedWriter, File, FileWriter, Writer}

trait WriteSupport {

  def withWriter(path: String)(f: Writer => Unit): Unit ={
    var writer: Writer = null
    try {
      val file = new File(path)
      if (!file.exists()) file.createNewFile()
      writer = new BufferedWriter(new FileWriter(file))
      f(writer)
      writer.flush()
    } finally {
      if (writer != null) writer.close()
    }
  }
} 
开发者ID:notyy,项目名称:CodeAnalyzerTutorial,代码行数:20,代码来源:WriteSupport.scala


示例7: pos

//设置package包名称以及导入依赖的类
package mjis

import java.io.Writer

trait Finding {
  def pos: Position
  def severity: Severity
  def msg: String

  override def toString = s"$pos $severity: $msg"
}

object Finding {
  def printAll(findings: Seq[Finding], sourceLines: Iterable[String], writer: Writer): Unit = {
    var curLine = 1
    var curSourceLines = sourceLines
    findings sortBy (_.pos) foreach (f => {
      writer.write(f.toString)
      writer.write(System.lineSeparator)
      if (f.pos.line >= 1) {
        curSourceLines = curSourceLines.drop(f.pos.line - curLine)
        curLine = f.pos.line
        curSourceLines.headOption match {
          case Some(lineContents) =>
            writer.write(f.pos.longString(lineContents))
            writer.write(System.lineSeparator)
          case _ =>
        }
      }
    })
  }
} 
开发者ID:jspam,项目名称:mjis,代码行数:33,代码来源:Finding.scala


示例8: ResultWriter

//设置package包名称以及导入依赖的类
package de.aquanauten.insights

import java.io.{BufferedWriter, File, FileWriter, Writer}

object ResultWriter {

  def writeFile(fileName: String)(writeFn: Writer => Unit): Unit = {
    val file = new File(fileName)
    file.getParentFile.mkdirs()
    val writer = new BufferedWriter(new FileWriter(file))
    try {writeFn(writer)} finally {writer.close()}
  }

  def writeDependencies(packageFile: String, packageDependencies: Dependencies): Unit = {
    // write dot file
    writeFile(packageFile + ".dot") (_.write(Rendering.render(packageDependencies)(DotRendering.DependencyRendering)))
    // write plantuml file
    writeFile(packageFile + ".puml") (_.write(Rendering.render(packageDependencies)(PlantUMLRendering.DependencyRendering)))
    // write json file
    writeFile(packageFile + ".json") (_.write(Rendering.render(packageDependencies)(JsonRendering.DependencyRendering)))
  }

  def writeClasses(targetDir: String, classFile: String, compileUnit: CompileUnit): Unit = {
    // global view
    writeFile(s"$targetDir/$classFile.json") { _.write(JsonRendering.render(compileUnit)) }
    writeFile(s"$targetDir/$classFile.puml") { _.write(PlantUMLRendering.render(compileUnit)) }

    // per package view
    compileUnit.classes.groupBy(_.packageName).foreach { case (packageName, classes) =>
      writeFile(s"$targetDir/package/puml/$packageName.puml")(_.write(PlantUMLRendering.render(CompileUnit(classes))))
    }
  }
} 
开发者ID:aquamatthias,项目名称:scala-insights,代码行数:34,代码来源:ResultWriter.scala


示例9: writeJson

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

import java.io.{ BufferedWriter, ByteArrayOutputStream, OutputStreamWriter, StringWriter, Writer }
import java.nio.ByteBuffer


package object jackson extends WithJacksonMapper with JacksonParser with JacksonCompat {

  private[this] def writeJson(w: Writer, j: Json): Unit = {
    val gen = jsonGenerator(w)
    makeWriter(mapper).writeValue(gen, j)
    w.flush()
  }

  final def jacksonPrint(json: Json): String = {
    val sw = new StringWriter
    writeJson(sw, json)
    sw.toString
  }

  private[this] class EnhancedByteArrayOutputStream extends ByteArrayOutputStream {
    def toByteBuffer: ByteBuffer = ByteBuffer.wrap(this.buf, 0, this.size)
  }

  final def jacksonPrintByteBuffer(json: Json): ByteBuffer = {
    val bytes = new EnhancedByteArrayOutputStream
    writeJson(new BufferedWriter(new OutputStreamWriter(bytes, "UTF-8")), json)
    bytes.toByteBuffer
  }
} 
开发者ID:circe,项目名称:circe-jackson,代码行数:31,代码来源:package.scala


示例10: content

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

import java.io.{Reader, Writer}

import com.hypertino.binders.json.JsonBindersFactory
import com.hypertino.binders.value.{Obj, Value}
import com.hypertino.hyperbus.serialization.{ResponseDeserializer, SerializationOptions}

trait DynamicBody extends Body {
  def content: Value

  def serialize(writer: Writer)(implicit so: SerializationOptions): Unit = {
    import com.hypertino.binders.json.JsonBinders._
    import so._
    content.writeJson(writer)
  }

  def copy(
            contentType: Option[String] = this.contentType,
            content: Value = this.content
          ): DynamicBody = {
    DynamicBody(content, contentType)
  }
}

object DynamicBody {
  def apply(content: Value, contentType: Option[String]): DynamicBody = DynamicBodyContainer(contentType, content)

  def apply(content: Value): DynamicBody = DynamicBodyContainer(None, content)

  def apply(reader: Reader, contentType: Option[String]): DynamicBody = {
    JsonBindersFactory.findFactory().withReader(reader) { deserializer =>
      apply(deserializer.unbind[Value], contentType)
    }
  }

  def unapply(dynamicBody: DynamicBody) = Some((dynamicBody.contentType, dynamicBody.content))
}

private[model] case class DynamicBodyContainer(contentType: Option[String], content: Value) extends DynamicBody 
开发者ID:hypertino,项目名称:hyperbus,代码行数:41,代码来源:DynamicBody.scala


示例11: serialize

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

import java.io.{Reader, Writer}

import com.hypertino.binders.value._
import com.hypertino.hyperbus.serialization.{DeserializeException, SerializationOptions}

trait EmptyBody extends DynamicBody {
  override def serialize(writer: Writer)(implicit so: SerializationOptions): Unit = writer.write("{}")
}

case object EmptyBody extends EmptyBody {
  def contentType: Option[String] = None
  def content = Null
  def apply(reader: Reader, contentType: Option[String]): EmptyBody = {
    val body = DynamicBody.apply(reader, contentType)
    if (body.content.isEmpty)
      EmptyBody
    else {
      throw DeserializeException(s"EmptyBody is expected, but got: '${body.content}'")
    }
  }
} 
开发者ID:hypertino,项目名称:hyperbus,代码行数:24,代码来源:EmptyBody.scala


示例12: pipe

//设置package包名称以及导入依赖的类
package fr.hmil.roshttp.tools.io

import java.io.{ByteArrayOutputStream, OutputStream, Writer, _}

import scala.annotation.tailrec
import scala.reflect.ClassTag


  def pipe(in: Reader, out: Writer): Unit = {
    val buffer = newBuffer[Char]

    @tailrec
    def loop(): Unit = {
      val size = in.read(buffer)
      if (size > 0) {
        out.write(buffer, 0, size)
        loop()
      }
    }
    loop()
  }

  @inline
  private def newBuffer[T: ClassTag] = new Array[T](4096)
} 
开发者ID:hmil,项目名称:RosHTTP,代码行数:26,代码来源:IO.scala


示例13: MetricFamilySamplesEntity

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

import java.io.{StringWriter, Writer}
import java.util

import akka.http.scaladsl.marshalling.{ToEntityMarshaller, Marshaller}
import akka.http.scaladsl.model._
import io.prometheus.client.Collector.MetricFamilySamples
import io.prometheus.client.CollectorRegistry
import io.prometheus.client.exporter.common.TextFormat

case class MetricFamilySamplesEntity(samples: util.Enumeration[MetricFamilySamples])

object MetricFamilySamplesEntity {
  private val mediaTypeParams = Map("version" -> "0.0.4")
  private val mediaType = MediaType.customWithFixedCharset("text", "plain", HttpCharsets.`UTF-8`, params = mediaTypeParams)

  def fromRegistry(collectorRegistry: CollectorRegistry): MetricFamilySamplesEntity = {
    MetricFamilySamplesEntity(collectorRegistry.metricFamilySamples())
  }

  def toPrometheusTextFormat(e: MetricFamilySamplesEntity): String = {
    val writer: Writer = new StringWriter()
    TextFormat.write004(writer, e.samples)

    writer.toString
  }

  implicit val metricsFamilySamplesMarshaller: ToEntityMarshaller[MetricFamilySamplesEntity] = {
    Marshaller.withFixedContentType(mediaType) { s =>
      HttpEntity(mediaType, toPrometheusTextFormat(s))
    }
  }

} 
开发者ID:lonelyplanet,项目名称:prometheus-akka-http,代码行数:36,代码来源:MetricFamilySamplesEntity.scala


示例14: Apps

//设置package包名称以及导入依赖的类
package lp.template.common

import java.io.{PrintWriter, StringWriter, Writer}


object Apps {
  def getExceptionDetails(e: Throwable): String = {
    val stackTrace: String = getStackTrace(e)
    val s: String = "Exception details:%n  %s".format(stackTrace)

    // Remove trailing newline.
    s.trim
  }

  def getStackTrace(e: Throwable): String = {
    val sw: Writer = new StringWriter
    val pw: PrintWriter = new PrintWriter(sw)
    e.printStackTrace(pw)
    sw.toString
  }
} 
开发者ID:leigh-perry,项目名称:template-wizard,代码行数:22,代码来源:Apps.scala


示例15: Csv

//设置package包名称以及导入依赖的类
package controllers

import java.io.{StringWriter, Writer}

import com.github.tototoshi.csv.CSVWriter
import org.intracer.finance.{Dictionary, Operation}

object Csv {

  def writeStringBuffer(data: Seq[Seq[Any]]): StringBuffer = {
    val writer = new StringWriter()
    write(data, writer)
    writer.getBuffer
  }

  def writeRow(data: Seq[Any]): String = {
    val writer = new StringWriter()
    val csv = CSVWriter.open(writer)
    csv.writeRow(data)
    csv.close()
    writer.getBuffer.toString
  }

  def write(data: Seq[Seq[Any]], writer: Writer): Unit = {
    val csv = CSVWriter.open(writer)
    csv.writeAll(data)
    csv.close()
  }

  def exportOperations(operations: Seq[Operation]): Seq[Seq[String]] = {
    val header = Seq("Date", "Project", "Category", "Grant", "GrantItem", "Amount", "Account", "Description")

    val rows = operations.map { o =>
      Seq(
        o.date.toString.substring(0, 10),
        o.to.projectName,
        o.to.categoryName,
        o.to.grantName,
        o.to.grantItem.map(_.name).getOrElse(""),
        o.amount.map(_.toString).getOrElse(""),
        o.to.account.name,
        o.to.description
      )
    }

    header +: rows
  }

  def addBom(data: Seq[Seq[String]]): Seq[Seq[String]] = {
    val BOM = "\ufeff"
    val header = data.head
    val headerWithBom = (BOM + header.head) +: header.tail
    headerWithBom +: data.tail
  }
} 
开发者ID:intracer,项目名称:wmua-finance,代码行数:56,代码来源:Csv.scala


示例16: Starscream

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

import java.io.Reader
import java.io.Writer

import org.xml.sax.{XMLReader, Attributes, InputSource}
import org.xml.sax.helpers.XMLReaderFactory

import org.dom4j.io.XMLWriter


object Starscream {
  private implicit class FilterChain(val reader: XMLReader) {
    def chain(newReader: XMLReader => XMLReader): FilterChain =
      new FilterChain(newReader(reader))
  }

  def transformSVGFromReaderToWriter(
      reader: Reader,
      writer: Writer,
      scale:Float = 1.0f,
      minimum:Float = Float.MinValue)
      : Unit = {
    val filter =
      XMLReaderFactory.createXMLReader()
        .chain(new ScaleFilter(_, scale))
        .chain(new MinimumFilter(_, minimum))
        .chain(new StripWhitespaceFilter(_, "id"))
        .chain(new StripWhitespaceFilter(_, "href"))
        .reader
    val xmlWriter = new XMLWriter(writer)
    filter.setContentHandler(xmlWriter)
    filter.parse(new InputSource(reader))
  }
} 
开发者ID:iOffice,项目名称:starscream,代码行数:36,代码来源:Starscream.scala


示例17: withStringParser

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

import java.io.{Reader, Writer}

import com.hypertino.binders.core.{BindOptions, Deserializer, Serializer}
import com.hypertino.binders.json.api.{JsonBindersFactoryApi, JsonGeneratorApi, JsonParserApi}
import com.hypertino.inflector.naming.{Converter, PlainConverter}

import scala.scalajs.js
import scala.scalajs.js.JSON

trait JsonBindersFactory[C <: Converter, S <: Serializer[C], D <: Deserializer[C]]
  extends JsonBindersFactoryApi[C, S, D] {

  override def withStringParser[T](jsonString: String)
                                  (codeBlock: D ? T)
                                  (implicit bindOptions: BindOptions): T = {
    val adapter = new JsParserAdapter(JSON.parse(jsonString))
    val jds = createDeserializer(adapter)
    codeBlock(jds)
  }

  override def withReader[T](reader: Reader)
                            (codeBlock: (D) ? T)
                            (implicit bindOptions: BindOptions): T = {
    val stringBuilder = new StringBuilder
    val len = 256
    val buffer = new Array[Char](len)
    var readed = len
    while (readed == len) {
      readed = reader.read(buffer, 0, len)
      stringBuilder.append(buffer, 0, readed)
    }
    withStringParser(stringBuilder.toString())(codeBlock)
  }

  def withJsonObjectParser[T](jsonObject: js.Dynamic)
                             (codeBlock: D ? T)
                             (implicit bindOptions: BindOptions): T = {
    withJsonParserApi(new JsParserAdapter(jsonObject))(codeBlock)
  }

  override def withWriter(writer: Writer)
                         (codeBlock: S ? Unit)
                         (implicit bindOptions: BindOptions): Unit = {
    withJsonGeneratorApi(new JsGeneratorAdapter(writer))(codeBlock)
  }
}

object JsonBindersFactory {
  implicit val defaultJsonBindersFactory = new DefaultJsonBindersFactory[PlainConverter.type]
  def findFactory[C <: Converter, S <: Serializer[C], D <: Deserializer[C]]()
    (implicit factory: JsonBindersFactory[C, S, D]): JsonBindersFactory[C, S, D] = factory
} 
开发者ID:hypertino,项目名称:json-binders,代码行数:55,代码来源:JsonBindersFactory.scala


示例18: createSerializer

//设置package包名称以及导入依赖的类
package com.hypertino.binders.json.api

import java.io.{Reader, StringReader, StringWriter, Writer}

import com.hypertino.binders.core.{BindOptions, Deserializer, Serializer}
import com.hypertino.inflector.naming.Converter

trait JsonBindersFactoryApi[C <: Converter, S <: Serializer[C], D <: Deserializer[C]] {
  def createSerializer(jsonGenerator: JsonGeneratorApi)(implicit bindOptions: BindOptions): S
  def createDeserializer(jsonParser: JsonParserApi)(implicit bindOptions: BindOptions): D
  def prettyPrint: Boolean = false

  def withStringParser[T](jsonString: String)(codeBlock: D ? T)(implicit bindOptions: BindOptions): T  = {
    val reader = new StringReader(jsonString)
    try {
      withReader[T](reader)(codeBlock)
    } finally {
      reader.close()
    }
  }

  def withStringGenerator(codeBlock: S ? Unit)(implicit bindOptions: BindOptions): String = {
    val writer = new StringWriter()
    try {
      withWriter(writer)(codeBlock)
    } finally {
      writer.close()
    }
    writer.toString
  }

  def withJsonParserApi[T](jsonParserApi: JsonParserApi)(codeBlock: D ? T)(implicit bindOptions: BindOptions): T = {
    val jds = createDeserializer(jsonParserApi)
    codeBlock(jds)
  }

  def withJsonGeneratorApi(jsonGeneratorApi: JsonGeneratorApi)(codeBlock: S ? Unit)(implicit bindOptions: BindOptions): Unit = {
    val js = createSerializer(jsonGeneratorApi)
    codeBlock(js)
  }

  def withReader[T](reader: Reader)(codeBlock: D ? T)(implicit bindOptions: BindOptions): T

  def withWriter(writer: Writer)(codeBlock: S ? Unit)(implicit bindOptions: BindOptions): Unit
} 
开发者ID:hypertino,项目名称:json-binders,代码行数:46,代码来源:JsonBindersFactoryApi.scala



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Scala Directory类代码示例发布时间:2022-05-23
下一篇:
Scala feature类代码示例发布时间: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