Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SequenceInputStream issue . it cant read all the streams in it

 
anas alsarairah
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello
i have an application that receives a list of PDF streams and then and then tries to merge them together into one single stream using SequenceInputStream class but the problem when i try to write the SequenceInputStream it doesnt write all the expected streams that have been included in the SequenceInputStream .... and please see the code beneath



please anyone help me on this
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. When posting code, please UseCodeTags(⇐click) so it will be readable.

2. How are you determining that it's "not working"? That is, what is the exact behavior that you are observing?

3. I don't think this even can work. I don't think you can create a valid PDF file by concatenating together other PDF files. Just because it works for text files doesn't mean it will work for other formats, and in fact, for the vast majority of other formats, it won't work.
 
anas alsarairah
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello
tanks for your reply
well what i do is that i create a list with 2 input streams and then i create a sequence input stream object from the list then i start writing the sequence to a single output file ... now the problem is that only the last file gets written to the output file and the first one somehow disappear

thanks
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anas alsarairah wrote:hello
tanks for your reply
well what i do is that i create a list with 2 input streams and then i create a sequence input stream object from the list then i start writing the sequence to a single output file


Yes, that much was clear from the original post. As I said in my previous reply, I don't think that's can produce a valid file with PDF.

... now the problem is that only the last file gets written to the output file and the first one somehow disappear


How exactly are you determining this? What exact steps are you taking and what's the exact behavior you're seeing? I can't help you with your code until I read it, and I won't read it if you don't UseCodeTags(⇐click) to format it properly.

My advice is this: First get it working with plain text files:



We know this technique can work with text files. We don't know that it can work with PDFs. Once you get it working with text files, then try it with your PDFs. If you're still having a problem, then, as I suspected, it's not possible with PDFs.
 
anas alsarairah
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok ... now i have used code tags if you would like to have a look ... but my question now how can i do that i mean how can i merg pdf streams ... whats the best way please

thanks
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anas alsarairah wrote:ok ... now i have used code tags if you would like to have a look


First try it with text files. If you can't get that to work, post that code and provide details of what's going wrong.

how can i merg pdf streams


If I'm correct and this approach can't work, then you won't be "merging streams." You'll be combining documents.

You'll have to either read up on the PDF format and build a tool that can parse the existing PDFs and combine them into one, or you'll have to find a library that can read PDFs and a library that can write PDFs (may or may not be the same library), use those to bring the PDFs into an object model, combine that object model into a single document, and write it out. I know iText can be used for writing PDFs. Don't know if it can read them.
 
anas alsarairah
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well yes i tried it and its working for text files

i wrote in the first text file (anas )and in the second one (alsarairah )
and the resultant file had the following (anasalsarairah)
which combines the content of the text files

thanks
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anas alsarairah wrote:well yes i tried it and its working for text files


Then clearly this approach is not valid for PDF, so you'll need something that can parse them, for starters.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic