• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Newbie File Questions

 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry guys, I've forgotten all my File stuff. Been years.

I'm trying to:
1) Make a backup file of "pork.css", "pork.bak.css"
2) Open "pork.css" and write to it.

here's the basic approach I started.


Which results in:
I think I'm referencing the file wrong. What's the correct way to find the file?

[ June 16, 2006: Message edited by: Garrett Smith ]
[ June 16, 2006: Message edited by: Garrett Smith ]
 
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Simply read the bytes from a FileInputStream and write them to an OutputStream. It is not necessary that you create the file for the OuputStream. It will be created automatically if it does not exist.

For instance, this code copies the bytes from an InputStream into a OutputSream:



You could invoke this code from any other method like this:

 
It is an experimental device that will make my mind that most powerful force on earth! More powerful than this tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic