FileDocCategorySizeDatePackage
copyafile.javaAPI DocExample2740Mon Jan 18 13:55:10 GMT 1999None

CopyAFile

public final class CopyAFile extends Object
Purpose: copies one file into another
version
1.0 December 96
author
Ilya Tilevich

Fields Summary
private static boolean
m_bDebug
private FileInputStream
fileName
private BufferedInputStream
bufferedInput
private DataInputStream
dataIn
private FileOutputStream
writeOut
private DataOutputStream
dataWrite
Constructors Summary
public CopyAFile(String inFile, String outFile)
Purpose: Constructor

param
inFile - input file name
param
outFile - output file name
exception
IOException if there are errors during fiels opening


	                        	 

	     
		try{
	            fileName = new FileInputStream(inFile);
		    //Creates an instance of the class BufferedInputStream
		    //named bufferedInput
		   //bufferedInput receives the stream from the fileInputStream
		   //fileName ad it is read
		   bufferedInput = new BufferedInputStream(fileName);
		   dataIn = new DataInputStream(bufferedInput);
		   
		   writeOut = new FileOutputStream(outFile);
		   dataWrite = new DataOutputStream(writeOut);
			
		}
		catch(FileNotFoundException e){
		    System.out.println("File Not Found");
		    return;
	    }
		catch(Throwable e) {
	        System.out.println("Error in opening file");
	        return;
	    }


	
Methods Summary
public voidDoCopy()
Purpose: Copies a file

exception
IOException if error happens


		int iCh;
		try{
	        
			while((iCh = dataIn.read())!=-1){
				dataWrite.writeByte(iCh);
				if(m_bDebug)
				   System.out.println(iCh);
							
			}
				
			fileName.close();
	        dataWrite.close();
	    }
						
		catch(IOException e) {
	          System.out.println("Error in reading file");
	    }
	
				
		
		catch(Throwable e){
			System.out.println("Error in writing to file");
		}