• 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

Help! Please! Problem with FileInputStream

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am developing a Java App that will read from a directory and use MQSeries to put the files from the directory on the queue. I got the code working for a file, but can't get it to work if I use a directory instead of a file. I can put the file contents on the queue but not the files from a directory. Thanks in advance to anyone who replies!!!

[This message has been edited by Rachel West (edited August 16, 2001).]
 
Rachel West
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everyone, I solved this problem myself. If you run into it, make sure you create a new from_file and increment it in your while loop like so:
for(int i =0; i < entries.length; i++)
{
File from_file2 = new File(from_file, entries[i]);
//create input stream
from = new FileInputStream(from_file2);
while((bytes_read = from.read(buffer)) != -1) //read until EOF
{
to.write(buffer, 0, bytes_read);
sendmsg.write(buffer, 0, bytes_read);

}

}
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic