Results 1 to 2 of 2
Thread: Stream Object Initialization
- 11-10-2012, 08:34 PM #1
Member
- Join Date
- Nov 2012
- Posts
- 1
- Rep Power
- 0
Stream Object Initialization
Now I am getting compile time error at line 30 and 38 that 'fin' might not have been initialized. but its perfectly to write it this way
Java Code:import java.io.*; class CopyFile { public static void main(String args[]) throws IOException { int i; FileInputStream fin; FileOutputStream fout= new FileOutputStream(args[1]); try{ //open input file try{ fin = new FileInputStream(args[0]); } catch(FileNotFoundException e){ System.out.println("Input file Not Found"); return; } //open output file try{ fout = new FileOutputStream(args[1]); } catch(FileNotFoundException e){ System.out.println("Error Opening File"); } } catch(ArrayIndexOutOfBoundsException e){ System.out.println("usage: Copyfile From to"); } try{ do{ i = fin.read(); if(i!= -1) fout.write(i); }while(i != -1); } catch(IOException e){ System.out.println("file error"); } fin.close(); fout.close(); } }
- 11-12-2012, 06:56 AM #2
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 780
- Rep Power
- 4
Similar Threads
-
Array of object initialization
By rybo85 in forum New To JavaReplies: 8Last Post: 05-03-2012, 05:49 AM -
Problem with Object Stream
By er.raj in forum New To JavaReplies: 6Last Post: 03-13-2012, 03:38 PM -
Input Stream as an Object?
By sehudson in forum New To JavaReplies: 1Last Post: 03-12-2011, 12:37 AM -
Object Input Stream EOFException
By FlyNn in forum New To JavaReplies: 1Last Post: 12-18-2010, 12:33 PM -
Err : java.io.IOException: unknown object in stream: 14
By Deepa in forum New To JavaReplies: 0Last Post: 07-08-2009, 08:10 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks