This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Java in General and the fly likes Attempting to Copy Files using Threads... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Attempting to Copy Files using Threads..." Watch "Attempting to Copy Files using Threads..." New topic
Author

Attempting to Copy Files using Threads...

Abhijit Kolhatkar
Greenhorn

Joined: Sep 14, 2006
Posts: 10
Hi All,
Attempting to Read a file and write it using Thread
Following is my implementation:



in_file and out_file are obtained as below: (In the Constructor of the Thread Class.



Now, following is the code in the main method of CopyFiles class which runs this Thread:



In place of INPUTFILE and OUTPUTFILE I have given FULL PATH of the files.

My input file is having only 5 rows as below:

The code is excuting without errors but NONE OF THE ROWS is getting written..
I have checked by debugging the code in Eclipse and even the While loop in RUN method is working but no out put is getting written....
Can someone point out the problem??

Thanks
Abhijit Kolhatkar
Greenhorn

Joined: Sep 14, 2006
Posts: 10
Ahhhh.....
My appologies...
The code was behaving like that because I DIDNT CLOSE THE STREAMS AFTER THE LOOP....
By putting the statements:



I was able to make the code work...

Moderators/Admins....Will you kindly close this thread?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Attempting to Copy Files using Threads...