IO Section Index
Part of the OpenJDK project, NIO.2 adds new I/O capabilities designed to simplify Java application development.
Is there a way to read all the items out of an NIO Buffer into an array to pass onto JNI (or for some other purpose)?
The Buffer class has an array() method added in 1.6 that allows you to get the backing buffer in a single call. This can be passed on to native code or to some method that requires an array to wor...more
A BufferOverflowException happens when the target buffer is full and you try to put something into it. A BufferUnderflowException happens when the source buffer is empty and you try to get somethi...more
The first argument to the printf method is the formatting string. While this will typically display the string you want, if it includes something like a % in it, it won't and will try to interpret...more
Preservation of the timestamp changed with Java 6. Prior versions used the time of extraction.
Prior to Java 6, the limit was 2000. That limit doesn't exist with Java 6.
Apart from the accept all filter, until Java 6, there were no predefined filters. Java 6 introduces the FileNameExtensionFilter, allowing you to define one or more types of files for the user to s...more
Pre-Java 6, you had to either use native code or fork off a platform specific command in a sub-process. With Java 6, there is a setWritable() method.
The Console class has methods to read console input with readLine() and readPassword(). These methods throw IOError instead of IOException. My best guess at why the difference is becasue IOError i...more
You can get the output into a file instead of the console / command prompt as follows: System.setOut(new PrintStream(new FileOutputStream("Test.txt"))); System.out.println("Hello How r u"); No...more
The toURL() method of File does not properly escape characters that aren't valid in a URL. You can write better code today without waiting for Java 6 by calling the toURL() method after calling to...more
Assuming you are on a platform that supports the attribute, you can call the setExecutable() method of File. Of course, you'll need to wait for Java 6 to do this. Prior versions of standard Java d...more
How can I accept a password from the console without an echo?
How do I print high-order characters to the console? Whenever I use System.out.println(), it chops off anything above seven bits.
System.out is an OutputStream. You need to work with a Writer object. With Java 6, you would use the printf() method of the new Console class, which is returned by the console() method of System.more
The ability to close() or flush() an object (typeically a stream) has been factored out into single method interfaces, Closeable and Flushable, respectively. Given that you sometimes need to opera...more