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


Scala WritableByteChannel类代码示例

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


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

示例1: WritableByteChannelSource

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

import java.nio.{ ByteBuffer }
import java.nio.channels.{ WritableByteChannel }

import isi.io.{ ByteSink ? BS }
import isi.convertible.{ ~?, Convertible }

trait ByteSinkInstances extends AnyRef {

  final implicit object WritableByteChannelSource extends BS[WritableByteChannel] {
    @inline
    def writeFrom(dest: WritableByteChannel, from: ByteBuffer): Int =
      dest write from
  }

  
  final implicit def `T ~=> WritableByteChanel: ByteSource`[T](implicit conv: T ~? WritableByteChannel): BS[T] =
    (dest, from) ? WritableByteChannelSource writeFrom (dest.convertTo[WritableByteChannel], from)

  final implicit object `ByteBuffer: ByteSink` extends BS[ByteBuffer] {
    @inline
    def writeFrom(dest: ByteBuffer, from: ByteBuffer): Int =
      `ByteBuffer: ByteSource` readInto (from, dest)
  }
} 
开发者ID:mouchtaris,项目名称:jleon,代码行数:29,代码来源:ByteSinkInstances.scala

示例2: exists

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

import java.nio.channels.{ WritableByteChannel, ReadableByteChannel }
import java.nio.file.{ StandardOpenOption ? opt, Files ? JFiles, Path ? JPath }

trait File extends Any {

  @inline
  final def exists(path: JPath): Boolean =
    JFiles exists path

  @inline
  final def create(path: JPath): WritableByteChannel =
    JFiles newByteChannel (path, opt.CREATE_NEW, opt.WRITE)

  @inline
  final def open(path: JPath): ReadableByteChannel =
    JFiles newByteChannel (path, opt.CREATE, opt.READ)

  @inline
  final def append(path: JPath): WritableByteChannel =
    JFiles newByteChannel (path, opt.CREATE, opt.WRITE, opt.APPEND)

  @inline
  final def truncate(path: JPath): WritableByteChannel =
    JFiles newByteChannel (path, opt.CREATE, opt.WRITE, opt.TRUNCATE_EXISTING)

  @inline
  final def remove(path: JPath): Unit =
    JFiles delete path
}

object File extends File 
开发者ID:mouchtaris,项目名称:jleon,代码行数:36,代码来源:File.scala


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