Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Help! Please! Problem with FileInputStream  RSS feed

 
Rachel West
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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
  • 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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!