Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

FileChannel class

 
Sue Nair
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?


Thanks
[ February 24, 2008: Message edited by: Jim Yingst ]
 
Balasubramanian Chandrasekaran
Ranch Hand
Posts: 215
Firefox Browser Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried your code.It looks like the code you have written does what you need.
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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:
 
Sue Nair
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you! It does work now.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic