www.pudn.com > jnp-src.rar > Convert.java


/*
 * Java Network Programming, Second Edition
 * Merlin Hughes, Michael Shoffner, Derek Hamner
 * Manning Publications Company; ISBN 188477749X
 *
 * http://nitric.com/jnp/
 *
 * Copyright (c) 1997-1999 Merlin Hughes, Michael Shoffner, Derek Hamner;
 * all rights reserved; see license.txt for details.
 */

import java.io.*; 
 
public class Convert { 
  public static void main (String[] args) throws IOException { 
    if (args.length != 4) 
      throw new IllegalArgumentException 
        ("Convert    "); 
    FileInputStream fileIn = new FileInputStream (args[1]); 
    FileOutputStream fileOut = new FileOutputStream (args[3]); 
    InputStreamReader inputStreamReader = 
      new InputStreamReader (fileIn, args[0]); 
    OutputStreamWriter outputStreamWriter = 
      new OutputStreamWriter (fileOut, args[2]); 
    char[] buffer = new char[16]; 
    int numberRead; 
    while ((numberRead = inputStreamReader.read (buffer)) > -1) 
      outputStreamWriter.write (buffer, 0, numberRead); 
    outputStreamWriter.close (); 
    inputStreamReader.close (); 
  } 
}