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