This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
For the FileStreams...i would like to know, if the fromFile should exist in the same dir frm where the prog is running , and secondly it can have any extension??? Thanx in advance !!!
import java.io.*; class CopyFile{ public static void main(String args[]){ FileInputStream fromFile; FileOutputStream toFile; try{ fromFile = new FileInputStream(args[0]); toFile = new FileOutputStream(args[1]); }catch(FileNotFoundException e){System.err.println("file not copied" + e); return; } catch(IOException e){System.err.println("file not copied" + e); return; } catch(ArrayIndexOutOfBoundsException e){System.err.println("file not copied" + e); return; } try{ int i= fromFile.read(); while ( i!= -1){ toFile.write(i); i= fromFile.read(); } } catch(IOException e){System.err.println("file not copied" + e); } try{ fromFile.close(); toFile.close(); } catch(IOException e){System.err.println("file not copied" + e);} } }
faiza haris
Ranch Hand
Joined: Oct 17, 2000
Posts: 173
posted
0
I found my ynswer.... Just give the right dir path of the files. Files can have any extention...txt or anyother