0
我正在玩scala(新手),並且正在嘗試使用Java 7 NIO(因爲我喜歡從容易開始)。但我無法解決如何實例化CompletionHandler接受。下面的代碼是錯誤的,我不能修復:我如何在Scala中實例化Java 7完成處理程序
package async
import java.nio.channels.AsynchronousServerSocketChannel
import java.net.InetAddress
import java.net.InetSocketAddress
import java.nio.channels.CompletionHandler
import java.nio.channels.AsynchronousSocketChannel
class AsyncServer (port: Int) {
val socketServer = AsynchronousServerSocketChannel.open();
socketServer.bind(new InetSocketAddress(port))
val connectionHandler = new CompletionHandler[AsynchronousSocketChannel, Integer](){
}
def init() = socketServer accept(1 , connectionHandler)
}