-
SequenceInputStream(complete)
I need to concatenate some file in a stream.
I'using SequenceInputStream and it work (if I write in a file using read method I can see the file concatenated).
But I see that there is a read(buf,offset,len) method that read "len" byte from stream and write them in a buf.
I have this problem:
1° file : len 10
2° file: len 5
3° file: len 8
So I read the file with FIleInputStream and insert them in a vector.
Vector v = new Vector();
v.add(new FileInputStream(PathFile1));
v.add(new FileInputStream(PathFile2));
v.add(new FileInputStream(PathFile3));
Enumeration e = v.elements();
SequenceInputStream ElencoFile = new SequenceInputStream(e);
so I have a Stream of len :23
ElencoFile.available() return 10 and not 23
If I use
Read(Buf,0,23)
in Buf I have only the first 10 byte (the stream of 1° file)
so I repeat this code for read all the stream
//read the first byte of stream
ElencoFile.read(Buf,Pos ,1);
//read the len of current stream
LenStream=ElencoFile.available();
Pos+=1;
//read len byte
ElencoFile.read(Buf,Pos,LenStream);
but I don't like this code.
is it possible read all byte of the stream white only 1 read?
my sequenceInputStream is very big
I'm not expert in java (I'm developing in .net) and this is my first program
thank you and sorry for my english
luca
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks