jGuru
Register Email     Password Forgot your
password?
HOME FAQS FORUMS DOWNLOADS ARTICLES PEERSCOPE LEARN

  Search   jGuru Search Help

View:
IO FAQ Home Page

FAQ Manager is guru John Zukowski PREMIUM.

Reading, writing, and filtering, bytes, characters, and objects, Java provides streams for them all. Or, add your own. [FAQ Previously managed by Tim Rohaly].

What's New

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)?
Java:API:IO:NIO
John Zukowski PREMIUM, Jun 3, 2007
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...
What's the difference between a BufferOverflowException and BufferUnderflowException?
Java:API:IO:NIO
John Zukowski PREMIUM, Jun 3, 2007
A BufferOverflowException happens when the target buffer is full and you try to put something into it. A BufferUnderflowException happens when the source...
What's wrong with the following statement: System.out.printf(object.toString())?
Java:API:IO
John Zukowski PREMIUM, Jun 3, 2007
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...

How do I get the JAR command to preserve the timestamp of the file in the archive?
Java:API:IO:Compression:Jar
John Zukowski PREMIUM, Oct 1, 2006
Preservation of the timestamp changed with Java 6. Prior versions used the time of extraction.
Is there a limit to the number of simultaneously open zip files?
Java:API:IO:Compression:Zip
John Zukowski PREMIUM, Oct 1, 2006
Prior to Java 6, the limit was 2000. That limit doesn't exist with Java 6.
How can I make a read-only file writable?
Java:API:IO:File System
John Zukowski PREMIUM, Jun 30, 2006
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.
What's with this new IOError class, when is it thrown?
Java:API:IO
John Zukowski PREMIUM, Jun 30, 2006
The Console class has methods to read console input with readLine() and readPassword(). These methods throw IOError instead of IOException. My best guess...
Are there any predefined file filters for a JFileChooser?
Java:API:Swing:Widgets, Java:API:IO:Filters
John Zukowski PREMIUM, Jun 30, 2006
Apart from the accept all filter, until Java 6, there were no predefined filters. Java 6 introduces the FileNameExtensionFilter, allowing you to define...
How do you get the output of a Java program in a text file instead of getting it on the console?
Java:API:IO
pratheesh k p , Mar 2, 2006
You can get the output into a file instead of the console / command prompt as follows: System.setOut(new PrintStream(new FileOutputStream("Test.t...
Why did the toURL() method of File get deprecated in Java 6? Should I stop using it now.
Java:API:IO:File System
John Zukowski PREMIUM, Jan 22, 2006
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...
How do I set the execute attribute of a file?
Java:API:IO:File System
John Zukowski PREMIUM, Dec 31, 2005
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...
How do I print high-order characters to the console? Whenever I use System.out.println(), it chops off anything above seven bits.
Java:API:IO
John Zukowski PREMIUM, Dec 5, 2005
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...
How can I accept a password from the console without an echo?
Java:API:IO
John Zukowski PREMIUM, Dec 5, 2005
Prior to Java 6, you couldn't. In Java 6, you have a readPassword() method in the new Console class.
How do I find out the default character set for the JVM?
Java:API:Internationalization:Character Sets, Java:API:IO:NIO
John Zukowski PREMIUM, Jul 31, 2005
Added to JDK 5.0, you can call the defaultCharset() method of the CharSet class, found in the java.nio.charset package. This is apt to depend upon the...
How do I print to a file?
Java:API:IO
John Zukowski PREMIUM, Jul 31, 2005
Typically, you would create a FileOutputStream and pass it to the PrintStream constructor. Starting with 5.0, you can pass the File or String name for...
Why would I want to use the Appendable interface?
Java:API:IO
John Zukowski PREMIUM, Jul 31, 2005
The Appendable interface and its append() methods are implemented in classes that support adding characters to the end of an object, typically a stream....
What is the deal with the Closeable and Flushable interfaces?
Java:API:IO
John Zukowski PREMIUM, Jul 31, 2005
The ability to close() or flush() an object (typeically a stream) has been factored out into single method interfaces, Closeable and Flushable, respectively....
Why can't I use Unicode supplementary characters in JDK 1.4?
Java:API:IO, Java:Language
John Zukowski PREMIUM, Jun 30, 2005
JDK 5.0 added support for code points above U+FFFF. Additional information is available from Supplementary Characters in the Java Platform.
How do I read formatted input from the command line?
Java:API:IO
John Zukowski PREMIUM, Jun 30, 2005
The java.util.Scanner constructor takes a file, channel, input stream, or reader as an argument and lets you read an int (with nextInt()), read a line...
How do I print a JTable?
Java:API:Swing:Widgets, Java:API:IO:Printing
John Zukowski PREMIUM, Jun 30, 2005
JDK 5.0 provides built in support for printing tables. Just call the print() method of JTable. Here's an example of such. import javax.swing.*; import...
« previous beginning next »


Ask A Question



Related Links

IO Forum

I/O in Java 2 SDK

Java I/O package documentation

Lesson: Reading and Writing (Sun Tutorial)

jGuru Serialization FAQ

Wish List
Features
About jGuru
Contact Us

 




JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
IBM Whitepaper: Innovative Collaboration to Advance Your Business
Internet.com eBook: Real Life Rails
Avaya Article: Call Control XML - Powerful, Standards-Based Call Control
Internet.com eBook: The Pros and Cons of Outsourcing
Go Parallel Article: Scalable Parallelism with Intel(R) Threading Building Blocks
Internet.com eBook: Best Practices for Developing a Web Site
IBM CXO Whitepaper: The 2008 Global CEO Study "The Enterprise of the Future"
Avaya Article: Call Control XML in Action - A CCXML Auto Attendant
Go Parallel Article: James Reinders on the Intel Parallel Studio Beta Program
IBM CXO Whitepaper: Unlocking the DNA of the Adaptable Workforce--The Global Human Capital Study 2008
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
Go Parallel Article: Getting Started with TBB on Windows
HP eBook: Storage Networking , Part 1
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Go Parallel Video: Intel(R) Threading Building Blocks: A New Method for Threading in C++
HP Video: Is Your Data Center Ready for a Real World Disaster?
Microsoft Partner Portal Video: Microsoft Gold Certified Partners Build Successful Practices
HP On Demand Webcast: Virtualization in Action
Go Parallel Video: Performance and Threading Tools for Game Developers
Rackspace Hosting Center: Customer Videos
Intel vPro Developer Virtual Bootcamp
HP Disaster-Proof Solutions eSeminar
HP On Demand Webcast: Discover the Benefits of Virtualization
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Microsoft Download: Silverlight 2 Software Development Kit Beta 2
30-Day Trial: SPAMfighter Exchange Module
Red Gate Download: SQL Toolbelt
Iron Speed Designer Application Generator
Microsoft Download: Silverlight 2 Beta 2 Runtime
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
IBM IT Innovation Article: Green Servers Provide a Competitive Advantage
Microsoft Article: Expression Web 2 for PHP Developers--Simplify Your PHP Applications
Featured Algorithm: Intel Threading Building Blocks - parallel_reduce
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES