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
ServerWatch.com Article: Virtualization Enters the SMB World
ITChannelPlanet.com Article: Emerging E-Discovery Market Grows More Vital for VARs
StoreVault Whitepaper: Introduction to Networked Storage
Oracle eBook: Implementing Business Intelligence in Your Organization
Hoovers Sales Tip: Building Credibility with New Clients
SAP Whitepaper: A Corporate Guide to Better Decisions Through IT
Microsoft Article: Flexibility, Agility the Keys to Dynamic IT
Microsoft Article: Improving Infrastructure Management for Mid-Size Companies
IBM Whitepaper: CIO Insights--Ignite Innovation by Fusing Business and IT
IBM Whitepaper: Transforming Legacy Apps into SOA
Internet.com eBook: All About Botnets
Intel Article: 8 Simple Rules for Designing Threaded Applications
Symantec Whitepaper: E-Mail Discovery--Worst-Case Scenarios Versus Best Practices
Ipswitch Whitepaper: Secure File Transfer In the Era of Regulatory Compliance
Symantec Whitepaper: A Unified, Proactive Approach to Endpoint Security
APC eBook: Putting the Green in IT
Intel Whitepaper: Best Practices for Developing and Optimizing Threaded Applications
Symantec Whitepaper: Emerging Trends in Fighting Spam
Oracle eBook: Guide to Oracle 11g and Database Migration
Symantec Whitepaper: Best Practices for IM Archiving & Compliance
Intel Article: The Challenges of Developing Multithreaded Processing Pipelines
Avaya Whitepaper: SIP--Creating Next-Generation Telecom Applications
Avaya Article: Event Processing Demands Real-Time Response for Communications-Enabled Business Apps
MessageLabs Whitepaper: Spam Spikes--A Real Risk to Your Business
Symantec Article: Guarding the Corporate Gateway
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Epicor Webcast: Requirements to Consider When Looking at ITSM Tools
Intel Video: Three Must-Knows for Parallelism
Microsoft: NXT Web Seminar Series
Microsoft Partner Program Video: The Secrets to Partner Success
Rational Asset Manager: Succeed with Asset-based Development
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
NXPowerLite: Desktop Edition Software Trial
IBM Rational Systems Development Solution e-Kit
IBM SOA Development Survival Guide eKit
Evaluate IBM Rational Build Forge Online
IBM Enterprise Architect eKit for SOA
Evaluate Rational Application Developer Online
Iron Speed Designer Application Generator
Symantec IM Detection Utility
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
IBM Overview Video: Next Generation Data Warehousing
IBM Tutorial: Intro to XML User Interface Language (XUL) Development
Microsoft How-to Article: Get Going with Silverlight and Windows Live
IBM Tutorial: The Ajax Transport Method
IBM Tutorial: Learning PHP
IBM Tutorial: Validating XML
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES