Java Doc for Channels.java in  » 6.0-JDK-Core » io-nio » java » nio » channels » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » io nio » java.nio.channels 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.nio.channels.Channels

Channels
final public class Channels (Code)
Utility methods for channels and streams.

This class defines static methods that support the interoperation of the stream classes of the java.io package with the channel classes of this package.


author:
   Mark Reinhold
author:
   Mike McCloskey
author:
   JSR-51 Expert Group
version:
   1.31, 07/05/05
since:
   1.4




Method Summary
public static  ReadableByteChannelnewChannel(InputStream in)
     Constructs a channel that reads bytes from the given stream.

The resulting channel will not be buffered; it will simply redirect its I/O operations to the given stream.

public static  WritableByteChannelnewChannel(OutputStream out)
     Constructs a channel that writes bytes to the given stream.

The resulting channel will not be buffered; it will simply redirect its I/O operations to the given stream.

public static  InputStreamnewInputStream(ReadableByteChannel ch)
     Constructs a stream that reads bytes from the given channel.

The read methods of the resulting stream will throw an IllegalBlockingModeException if invoked while the underlying channel is in non-blocking mode.

public static  OutputStreamnewOutputStream(WritableByteChannel ch)
     Constructs a stream that writes bytes to the given channel.

The write methods of the resulting stream will throw an IllegalBlockingModeException if invoked while the underlying channel is in non-blocking mode.

public static  ReadernewReader(ReadableByteChannel ch, CharsetDecoder dec, int minBufferCap)
     Constructs a reader that decodes bytes from the given channel using the given decoder.

The resulting stream will contain an internal input buffer of at least minBufferCap bytes.

public static  ReadernewReader(ReadableByteChannel ch, String csName)
     Constructs a reader that decodes bytes from the given channel according to the named charset.
public static  WriternewWriter(WritableByteChannel ch, CharsetEncoder enc, int minBufferCap)
     Constructs a writer that encodes characters using the given encoder and writes the resulting bytes to the given channel.

The resulting stream will contain an internal output buffer of at least minBufferCap bytes.

public static  WriternewWriter(WritableByteChannel ch, String csName)
     Constructs a writer that encodes characters according to the named charset and writes the resulting bytes to the given channel.



Method Detail
newChannel
public static ReadableByteChannel newChannel(InputStream in)(Code)
Constructs a channel that reads bytes from the given stream.

The resulting channel will not be buffered; it will simply redirect its I/O operations to the given stream. Closing the channel will in turn cause the stream to be closed.


Parameters:
  in - The stream from which bytes are to be read A new readable byte channel



newChannel
public static WritableByteChannel newChannel(OutputStream out)(Code)
Constructs a channel that writes bytes to the given stream.

The resulting channel will not be buffered; it will simply redirect its I/O operations to the given stream. Closing the channel will in turn cause the stream to be closed.


Parameters:
  out - The stream to which bytes are to be written A new writable byte channel



newInputStream
public static InputStream newInputStream(ReadableByteChannel ch)(Code)
Constructs a stream that reads bytes from the given channel.

The read methods of the resulting stream will throw an IllegalBlockingModeException if invoked while the underlying channel is in non-blocking mode. The stream will not be buffered, and it will not support the InputStream.mark mark or InputStream.reset reset methods. The stream will be safe for access by multiple concurrent threads. Closing the stream will in turn cause the channel to be closed.


Parameters:
  ch - The channel from which bytes will be read A new input stream



newOutputStream
public static OutputStream newOutputStream(WritableByteChannel ch)(Code)
Constructs a stream that writes bytes to the given channel.

The write methods of the resulting stream will throw an IllegalBlockingModeException if invoked while the underlying channel is in non-blocking mode. The stream will not be buffered. The stream will be safe for access by multiple concurrent threads. Closing the stream will in turn cause the channel to be closed.


Parameters:
  ch - The channel to which bytes will be written A new output stream



newReader
public static Reader newReader(ReadableByteChannel ch, CharsetDecoder dec, int minBufferCap)(Code)
Constructs a reader that decodes bytes from the given channel using the given decoder.

The resulting stream will contain an internal input buffer of at least minBufferCap bytes. The stream's read methods will, as needed, fill the buffer by reading bytes from the underlying channel; if the channel is in non-blocking mode when bytes are to be read then an IllegalBlockingModeException will be thrown. The resulting stream will not otherwise be buffered, and it will not support the Reader.mark mark or Reader.reset reset methods. Closing the stream will in turn cause the channel to be closed.


Parameters:
  ch - The channel from which bytes will be read
Parameters:
  dec - The charset decoder to be used
Parameters:
  minBufferCap - The minimum capacity of the internal byte buffer,or -1 if an implementation-dependentdefault capacity is to be used A new reader



newReader
public static Reader newReader(ReadableByteChannel ch, String csName)(Code)
Constructs a reader that decodes bytes from the given channel according to the named charset.

An invocation of this method of the form

 Channels.newReader(ch, csname)
behaves in exactly the same way as the expression
 Channels.newReader(ch,
 Charset.forName(csName)
 .newDecoder(),
 -1);

Parameters:
  ch - The channel from which bytes will be read
Parameters:
  csName - The name of the charset to be used A new reader
throws:
  UnsupportedCharsetException - If no support for the named charset is availablein this instance of the Java virtual machine



newWriter
public static Writer newWriter(WritableByteChannel ch, CharsetEncoder enc, int minBufferCap)(Code)
Constructs a writer that encodes characters using the given encoder and writes the resulting bytes to the given channel.

The resulting stream will contain an internal output buffer of at least minBufferCap bytes. The stream's write methods will, as needed, flush the buffer by writing bytes to the underlying channel; if the channel is in non-blocking mode when bytes are to be written then an IllegalBlockingModeException will be thrown. The resulting stream will not otherwise be buffered. Closing the stream will in turn cause the channel to be closed.


Parameters:
  ch - The channel to which bytes will be written
Parameters:
  enc - The charset encoder to be used
Parameters:
  minBufferCap - The minimum capacity of the internal byte buffer,or -1 if an implementation-dependentdefault capacity is to be used A new writer



newWriter
public static Writer newWriter(WritableByteChannel ch, String csName)(Code)
Constructs a writer that encodes characters according to the named charset and writes the resulting bytes to the given channel.

An invocation of this method of the form

 Channels.newWriter(ch, csname)
behaves in exactly the same way as the expression
 Channels.newWriter(ch,
 Charset.forName(csName)
 .newEncoder(),
 -1);

Parameters:
  ch - The channel to which bytes will be written
Parameters:
  csName - The name of the charset to be used A new writer
throws:
  UnsupportedCharsetException - If no support for the named charset is availablein this instance of the Java virtual machine



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.