You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
File Systems I<br />
Receive our newsletter with new tips! Almost 6,000 subscribers (by June 2001) can not be wrong!<br />
They read our tips every week! To subscribe to The <strong>Java</strong> FAQ Daily send empty e-mail to:<br />
javafaq-tips-subscribe@topica.com or visit at:<br />
http://www.topica.com/lists/javafaq-tips/<br />
File Systems I<br />
How does <strong>Java</strong> read the text files? Can <strong>Java</strong> read the files that are in other<br />
formats? Is the read file method in <strong>Java</strong> only recognizes the file in .txt or other text<br />
format?<br />
Answer: <strong>Java</strong> can read any text file ( using a java.io.FileReader for example ), the<br />
attribute at the end is an indictor and thus is not relevant as long as the actual code<br />
read is in the correct format. I It can read files that are in other formats bytes etc and<br />
if you have a wierd format you could extend the IO mechanism with some work to<br />
work with that.<br />
Q: Is it possible to choose a directory path instead of a file path in a swing<br />
FileChooser dialog box?<br />
Answer: Assume you have instance chooser of type JFileChooser, invoke...<br />
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);<br />
Q: Does anyone know the way to retrieve the path from where has been loaded<br />
the main class of an application, not the path from where has been launched the<br />
virtual machine?<br />
Answer: Please use something like this:<br />
path = System.getProperty("user.dir");<br />
Q: How to erase the content of (text) file without create/open file again (only do<br />
"new FileOutputStream(...)" once)?<br />
Answer: Try java.io.RandomAccessFile.setLength(0) if you're using JDK 1.2 or<br />
higher.<br />
If you don't have to keep the file, it may be easier to use<br />
file:///F|/350_t/350_tips/filesystems-I.htm (1 of 4) [2002-02-27 21:17:56]<br />
Visit us here and you will find<br />
much more tips!