FileIO 5.7 build: 9140 released: 2008-04-02 Amanuensis to show you how to write Java I/O code. Copyright (c) 2008 Canadian Mind Products. Java Applet (that can also be run as an application). Download from http://mindprod.com/products1.html#FILEIO ===> Free <=== Full source included. You may even include the source code, modified or unmodified in commercial programs that you write and distribute. May be used freely for any purpose but military. For more details on this restriction, see http://mindprod.com/roedy.html#NONMILITARY If you include any Canadian Mind Products code in your own applications, your app too must be labeled non-military use only. All Java jars and source code are included. ---- Prerequisites: This program runs under any OS, (e.g. Win2K/XP/Vista/OSX/Linux/Solaris/Vista64/AIX...) so long as you have <><> Java version 1.5 <><> or later installed. See http://mindprod.com/jgloss/installingjava.html for details. ---- Installing on a PC: Download source and compiled class files to run on your own machine as an application or Applet. First install a recent Java JDK or JVM. See http://mindprod.com/jgloss/installingjava.html. To install, extract the zip download with Winzip (or similar unzip utility) into any directory you please, often J:\ -- ticking off the “user folder names” option. To run as an application,type: java -jar J:\com\mindprod\fileio\fileio.jar parms adjusting as necessary to account for where the jar file is. ---- Installing on a MacIntosh: Use Safari to download source and compiled class files to run on your own machine as an application or Applet. Safari will automatically unpack the zip into ~/Downloads (version 10.5) [or on the Desktop (version 10.4 and earlier)]. First install a recent Java JDK or JVM. See http://mindprod.com/jgloss/installingjava.html. You may optionally move the download tree to a permanent home. To run as an application, without parameters, just double click the jar file. To run as an application with parameters, in bash shell type: open Terminal.app cd ~/Desktop java -jar com/mindprod/fileio/fileio.jar parms adjusting as necessary to account for where the jar file is. I don't have a MacIntosh, just a PC, so I can't test the programs for Mac compatibility. In theory they should work without problems, but in practice that does not always happen. If you have problems please, let me know, preferably with screenshots and complete verbatim error messages. ---- Rebuilding: The zip already contains the necessary class and jar files, so unless you modify the program, there is no need to recompile the source or rebuild the jar. Configure basedir="E:/" in rebuild.xml to the drive where your files are. Use ANT and rebuild.xml, not build.xml, to recompile and recreate the jar. ---- Use: I/O teaching tool that generates sample Java source code to read or write the console, a sequential file, a random access file, a String, an array of characters, an array of bytes, URL, HTTP CGI GET/POST, Socket or Pipe. It shows you how to read or write ASCII-8 bit characters (plain or locale-encoded), Unicode 16-bit characters, raw bytes, big endian binary, little endian binary, or serialised objects, buffered, unbuffered or gzip compressed. FileIO runs either as an application or as an applet that needs to run in JDK 1.5+ capable browser. Source code and sample HTML included. May be freely distributed and used for any purpose except military. It works by asking you 4 multiple choice questions about what you want to do. You fill in your choices in a dialog box at it instantly generates the corresponding code that you can copy/paste and modify. 1) What is the type of the source/target? - sequential file - random access file - String (in RAM i/o) - char[] (in RAM i/o) - byte[] (in RAM i/o) - URL (remote i/o) - HTTP CGI - socket - pipe 2) Do you want to read or write? 3) Which do you want: unbuffered, buffered or compressed? 4) What is the format of the data being read or written? - raw, untranslated, bulk, 8-bit bytes - default-encoded chars (usually 8-bit) - locale-encoded chars (usually 8-bit), e.g. IBM-OEM Cp437 - Unicode 16-bit chars - big-endian binary (Java standard) - little-endian binary (Intel standard) - serialised objects It generates 378 possible different example programs. This Applet does not yet give you any help with the Java 1.4 javax.imageio.ImageIO class or the java.nio classes: Buffer, ByteBuffer, ByteOrder, CharBuffer, DoubleBuffer, FloatBuffer, IntBuffer, LongBuffer, MappedByteBuffer or ShortBuffer. You can run it online at http://mindprod.com/applet/fileio.html without installing it. To install, Extract the zip download with Winzip, available from http://www.winzip.com (or similar unzip utility) into any directory you please, often C:\ -- ticking off the "user folder names" option. To run as an application, type: java -jar C:\com\mindprod\fileio\fileio.jar adjusting as necessary to account for where the jar file is. Version History 4.6 adds an about box, version checking, a warning about read not always giving all you ask for, and cleaner internals. 4.7 uses UTF-8 instead of Cp437 as the example encoding. 4.8 adds notes about the safety of bad line terminators on Reader files. 4.9 show how to set User-Agent and Request-Type for an HTTP GET. 5.0 2006-01-04 - add warnings about readUTF and writeUTF. 5.1 2006-03-05 5.2 2007-07-12 - add reference to com.mindprod.http package. convert to JDK 1.5 and Swing use of enum pass IntelliJ inspector. 5.3 2007-07-19 notes in GET/POST about HTTPClient, changed ordering. 5.4 2007-07-27 fixes errors is code generated for PIPE write and URL read. 5.5 2007-08-05 major rewrite. refactor, simplify, make code more orthogonal, generate code for more cases, timeouts. 5.6 2007-08-24 notes on where to get source for readBytesBlocking. 5.7 2008-04-02 display build, clean up spelling errors, lint the code.