IO Section Index | Page 4
There is no built in support for this. While you can create an ODBC DSN and use the JDBC bridge to the file, this can be a nuisance to do. Instead try the open source ExcelRead package, which allo...more
For any type of file, just use the setReadOnly() method of File to mark a file as read-only. There is no argument to make it writable once it is read-only.
The beta 3 release of Java 1.4 broke the class. See bug 4510323 for a description of the problem. Hopefully, this will be fixed for the first non-beta release.more
The JTextComponent provides a read() method to initialize the text component: JTextArea ta = new JTextArea(); Reader reader = new FileReader(filename); ta.read(reader, null); The sec...more
This is bug 4510323. You'll need to wait to see when it get fixed...
Here's a simple example of monitoring file read progress import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.FileInputStream; impo...more
While the Selector class is abstract, you can create one by calling the static open() method. This will create an instance of a Selector subclass. Behind the scenes, this is done through the selec...more
The Java Developer Connection provides a tutorial on the package at http://java.sun.com/jdc/technicalArticles/releases/1.4regex/.more
The javax.imageio package provides this for you in Java 1.4. Previousl versions had no standard support, though you could add third party libraries to standard Java for this. BufferedImage ou...more
My servlet reads the contents of a text file which I access using a File object. What issues are involved when this file is read concurrently by several different threads? Do I have to synchronize...more
How can I redirect the output of session.setDebug(true) so that I can capture it in the program that uses it?
The messages are hardcoded to go to System.out. The best you can do is redirect System.out to a ByteArrayOutputStream: session.setDebug(true); ByteArrayOutputStream os = new ByteArrayOutputStream...more
The java.nio.charset package include character set converters for you. To go from ByteBuffer to CharBuffer, you would do something like the following: ByteBuffer buffer = ... Charset charset = C...more
FileInputStream input = new FileInputStream(filename); FileChannel channel = input.getChannel(); int fileLength = (int)channel.size(); MappedByteBuffer buffer = channel.map(FileChannel.MAP_RO,...more
How are the mark() and reset() methods used with InputStream classes?
How can I detect if there is a floppy in the floppy drive using Java? javaw.exe takes over with the "No disk" dialog, even when I catch a Security Exception. How does one suppress this dialog?????