FileIO 6.2 build: 9639 released: 2014-05-10 compiled with: Java 1.8.0_131 Jet jet12.0-pro-x86/1.8.0_131 Amanuensis to show you how to write Java I/O code. Copyright: (c) 1997-2017 Canadian Mind Products. signed Java Applet (that can also be run as an application). Download from: http://mindprod.com/products1.html#FILEIO View HTML to run this program online at: http://mindprod.com/applet/fileio.html ---- Notes: You must install the Java JRE to use this program. See http://mindprod.com/jgloss/jgloss/jre.html This hybrid program is mainly designed to be used as an Applet in a browser but is can also be used from the command prompt, e.g. under Windows command.exe or JPSoft tcc.exe, formerly called the DOS box. Just clicking the programs in a directory listing will not do anything useful. Just typing the program names at the command prompt will not either. This program requires a manual install! See below. I put out an avalanche of free software into the world, and submit PAD files to hundreds of distribution sites, but I rarely hear back from anyone. What's happening? Does it all just work fine? It is so complicated nobody can figure out how to use it and they give up on it? It is it useful? Since everyone has the source, do people just fix the programs to their liking themselves? Did you have trouble installing? Do I presume you know too much? I would be happy to hear from you about your experiences, positive or negative and your requests for improvements. A one-line email to roedy@mindprod.com would be great. ===> Free <=== Full source included. You may even include the source code, modified or unmodified in free/commercial open source/proprietary 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/contact/nonmil.html If you include any Canadian Mind Products code in your own applications, your app too must be labelled non-military use only. http://mindprod.com/contact/nonmil.html All Java jars and source code are included. If you need the class files or Javadoc, you will have to build them yourself. To streamline the zip downloads, class files and Javadoc have been removed. ---- Prerequisites: This program runs under any OS that supports Java, (e.g.W2K/XP/W2003/Vista/W2008/W7-32/W7-64/W8-32/W8-64/Linux/LinuxARM/LinuxX86 /LinuxX64/Ubuntu/Solaris/SolarisSPARC/SolarisSPARC64/SolarisX86/SolarisX64/OSX/AIX...) so long as you have <><> Java version 1.8 <><> or later installed (32-bit or 64-bit Java). See http://mindprod.com/jgloss/installingjava.html for details. ---- Installing on a PC: Download source and compiled jar 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 use folder names option. To run as an application, type: java.exe %JAVA_OPTIONS -ea -jar J:\com\mindprod\fileio\fileio.jar {put any parms here} adjusting as necessary to account for where the jar file is. ---- Installing on a MacIntosh: Use Safari to download source and compiled jar 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. I don't have a MacIntosh, just a PC, so I can't test my Java 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. 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.exe -ea -jar com/mindprod/fileio/fileio.jar {put any parms here} adjusting as necessary to account for where the jar file is. ---- Rebuilding: The zip already contains the necessary jar files, so unless you modify the program, there is no need to recompile the source or rebuild the jar. Configure.java basedir="E:/" in rebuild.xml to the drive where your files are. Configure.java your certificate name with environment SET cert=mindprodcert2017rsa Configure.java your certificate password with environment SET jarsignerpassword=sesame Use ANT and rebuild.xml, not build.xml, to recompile and recreate the jar. ---- Use: File I/O is a 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.7+ 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 617 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 mindprod.com/applet/fileio.html without installing it. ---- Version History: 1.0 1997-12-17 1.1 1997-12-22 uses layouts generates BufferedReader.ReadLine() 1.2 1998-01-02 handles URLConnection handle append handle autoflush handle buffered on all types 1.3 1998-01-03 internal reorganisation O P E N comments consistent short variable naming conventions. StringBuilder renamed to String Buffered now applies to all file types RandomAccessFile 1.4 1998-01-04 make into both application and applet change reference to LEDataInputStream 1.5 1998-01-08 warnings about applets and writing URLs. 1.6 1998-01-09 reference to availability of LERandomAccessFile change way LERandomAccess constructor works 1.7 1998-01-12 add Sockets remove connect out URL output. - simplify interface to HowToProcess by making all methods static. 1.8 1998-01-13 add Pipes 1.9 1998-01-13 minor changes on how buffered handled fix erroneous deprecated comment. add readLine to more places. 2.0 1998-01-17 GZIPOutputStream support 2.1 1998-01-20 code to analyse a URL code to flush 2.2 1998-03-22 add ByteArrayInputStream ByteArrayOutputStream. redo code to check for supported cases. expectExceptions expectExceptionOnFlush expectExceptionOnClose computed as you go rather than trying to figure it out all in once place. 2.3 1998-04-13 single character read for BufferedReader. 2.4 1998-05-08 no url connect() on output. Activator HTML Compile on Symantec VC 2.5 SlickEdit code tidy 2.5 1998-06-24 add Javadoc. 2.6 1998-11-10 new address and phone. 2.7 1998-12-14 switch to jar file. use new colour scheme. check JVM version 2.8 1998-12-28 add sample HTML and BAT file. 2.9 1999-09-02 URLConnection.getContentLength 3.0 1999-09-03 warning about URL uploads. put connect back harmless if already connected. 3.1 1999-09-07 read/write get/post HTTP CGI 3.2 1999-10-08 support for encoding 3.3 1999-10-12 references to where to get ledatastream and FileTransfer 3.4 1999-10-21 warning about Netscape 3.5 1999-10-22 stronger warning about Netscape 3.6 2001-02-05 warning about readLine demanding a final \n 3.7 2001-03-07 better fileio.use file. 3.8 2002-02-15 use of .finish in compression. rename variables to better fit Sun conventions. variable Source/Target label that tracks read/write. label "Data Type" 3.9 2002-02-20 warning on pipes they are for inter-thread communication only. 4.0 2002-04-04 package name now lower case fitting Sun conventions 4.1 2002-04-19 replace term ASCII with accurate wordings throughout. autoflush for pipes and sockets. - rename all datatypes for greater clarity. 4.2 2003-05-19 better spacing. Notes about Serialisation. notes about -1 bytesRead means EOF. 4.3 2003-05-26 note about missing readLine method in unbuffered Readers. 4.4 2003-05-27 Dropped all Exception catching for simplicity. Redid code using StringBuilders instead of concatenation. use of readEverything for HttpURLConnections. 4.5 2004-05-04 add HEAD and turn off keep-alive 4.6 2004-06-09 warnings about read not giving all bytes/chars you ask for in one go. add version check safety add about box tidier add code. 4.7 2004-07-21 use UTF-8 instead of Cp437 as example encoding. 4.8 2005-06-24 notes on safety of bad line separators in Reader files. parameterised RELEASE_DATE. 4.9 2005-11-30 add User-Agent and setRequestMethod to URL 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 correct code generated for URL read, and PIPE write. 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 add build number to title 5.8 2009-12-21 use keyword final as much as possible in generated code. 5.9 2010-02-21 use of FastCat instead of StringBuilder. Generate code to use Aux buffering for Readers and Writers. 6.0 2010-12-06 support getResourceAsStream, FileReader, FileWriter. 6.1 2011-12-03 configurable Look and Feel 6.2 2014-05-10 optimal buffering ratios -30-