Create a file in memory [message #24223] |
Sun, 21 December 2008 17:00  |
Eclipse User |
|
|
|
Originally posted by: news.s237965939.online.de
I want to create a file stream in memory. In my case it's a midifile.
This file has a specified format. The header and other blocks have
variables of different types. A byte[] buffer is associated to the
class. My question now is how can I easily write my different variables
sequentially into the buffer? How will the headerChunk.write() function
look like? Here comes a little excerpt.
TIA,
Hans
public class MidiFile extends ByteArrayInputStream {
class headerChunk {
final byte[] Id = { 'M', 'T', 'h', 'd' };
final int Size = 6;
short Format = 0;
short NumTracks = 1;
short TimeDiv;
void write(....); ????
}
}
|
|
|
|
|
|
Re: Create a file in memory [message #569312 is a reply to message #24223] |
Mon, 22 December 2008 08:06  |
Eclipse User |
|
|
|
Hello Hans,
There are two classes that will help you, DataInputStream and
DataOutputStream. These classes let an application read primitive Java
data types from an underlying input stream in a machine-independent way.
Hope it helps you!
Regards,
David Marques
|
|
|
Re: Create a file in memory [message #569348 is a reply to message #24266] |
Tue, 23 December 2008 06:35  |
Eclipse User |
|
|
|
Originally posted by: news.s237965939.online.de
Hi David,
it's you again to give me tips. I've got it runnning now, not quite in a
manner which I hoped, but it works reliably.
Thanks and Merry Christmas,
Hans
David Marques wrote:
> Hello Hans,
>
> There are two classes that will help you, DataInputStream and
> DataOutputStream. These classes let an application read primitive Java
> data types from an underlying input stream in a machine-independent way.
>
> Hope it helps you!
>
> Regards,
>
> David Marques
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.07453 seconds