• 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

SequenceInputStream not reading the second file

 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Team,

I want to ask your help since you might have gone through this before. I tried the SequenceInputStream, unfortunately it's not reading the second file, the result file shows only the XYZ file only, it didnt really add the other one. Please help me out on finding what I might have missed in this?


Vector files = new Vector();
FileInputStream f1 = new FileInputStream("C:\\FileNet\\XYZ.pdf");
FileInputStream f2 = new FileInputStream("C:\\FileNet\\documents\\ABC.pdf");
files.add(f1);
files.add(f2);
Enumeration enu = files.elements();
FileOutputStream fostream = new FileOutputStream("Result.pdf");
//InputStreamEnumerator e = new InputStreamEnumerator(files);
InputStream input = new SequenceInputStream(enu);
fostream.write(IOUtils.toByteArray(input));
input.close();
fostream.close();

Please let me know if you need more information on this.

Thanks
 
Master Rancher
Posts: 4921
74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I suspect it is concatenating the two files, but your PDF viewer doesn't know it should look for a second file after the end of the data for the first one. I'm not really familiar with PDF's internal format, but it may not support simple concatenation like that. To test this theory, take a look at the files sizes of the two input files and one output file. Is the output size equal to the sum of the input sizes?
 
Frederik Ericsson
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No worries, I got the answers from the previous posts, this may not work for all document/image formats, works well with .txt, I need to use something different. file1 size is equal to output file size.
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mike Simmons wrote:I'm not really familiar with PDF's internal format, but it may not support simple concatenation like that.



It doesn't.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Fedrick

What did you do to fix that ? I also ran into same issue.Could you please paste me the post you have gone through.
 
Saloon Keeper
Posts: 15630
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please show us what code you've tried, and tell us what kinds of files you want to concatenate and for what reason.
 
Marshal
Posts: 79471
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
PG: welcome to the Ranch FE is no longer active here, so you shouldn't expect an answer from him.
 
Every snowflake is perfect and unique. And every snowflake contains a very tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic