• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

FileChannel class

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried your code.It looks like the code you have written does what you need.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you! It does work now.
 
reply
    Bookmark Topic Watch Topic
  • New Topic