File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes FileChannel class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "FileChannel class" Watch "FileChannel class" New topic

FileChannel class

Sue Nair

Joined: Jan 28, 2008
Posts: 6
I am trying to finish up a homework assignment and I am having a little bit of trouble. I am using the FileChannel class to copy input from one file to another. My program will compile but I am not for sure what else to do? I think my problem is in creating a file to be copied. I have created a folder sDir and put in a file.Is this all I need to do? I am not for sure how to have my program create the tDir and copy the contents of sDir. Could someone please look at my code and help me?

[ February 24, 2008: Message edited by: Jim Yingst ]
Balasubramanian Chandrasekaran
Ranch Hand

Joined: Nov 28, 2007
Posts: 215

Have you tried your code.It looks like the code you have written does what you need.
Rob Spoor

Joined: Oct 27, 2005
Posts: 20193

I think you have made a logical mistake here, which happens to be solved by a syntactical mistake.

You should add a ! before targetDir - you want to create the folder if it doesn't exist, not if it already exists.

Now your code still works because of the ; right after the if. Right now, your code is equal to this:

So if you add the ! and remove the ; you should be fine:

How To Ask Questions How To Answer Questions
Sue Nair

Joined: Jan 28, 2008
Posts: 6
Thank you! It does work now.
I agree. Here's the link:
subject: FileChannel class
It's not a secret anymore!