wood burning stoves 2.0*
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 Android Security Essentials Live Lessons this week in the Android 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...
 
Similar Threads
trouble trying to read a file and copy it to another....
Copy file
trying to read from a file and write to a file..but..
xls file
write reversed lines to a file