16.11.2013 Aufrufe

Programmieren in Java - HostFiXX.de

Programmieren in Java - HostFiXX.de

Programmieren in Java - HostFiXX.de

MEHR ANZEIGEN
WENIGER ANZEIGEN

Erfolgreiche ePaper selbst erstellen

Machen Sie aus Ihren PDF Publikationen ein blätterbares Flipbook mit unserer einzigartigen Google optimierten e-Paper Software.

<strong>Programmieren</strong> <strong>in</strong> <strong>Java</strong><br />

8.1.3 Die Klasse ObjectInputStream<br />

An e<strong>in</strong>en E<strong>in</strong>gebestrom kommt man über e<strong>in</strong>en InputStream. Da die Daten häufig<br />

aus e<strong>in</strong>er Datei kommen ist dies häufig e<strong>in</strong> FileInputStream, <strong>de</strong>r mit e<strong>in</strong>em<br />

ObjectInputStream verknüpft wird. Die Metho<strong>de</strong> readObject() liest das<br />

Objekt, f<strong>in</strong><strong>de</strong>t heraus, was für e<strong>in</strong> Typ es ist und holt, falls nötig, auch noch Objekte,<br />

auf die verwiesen wird.<br />

InputStream<br />

{ abstract }<br />

ObjectInputStream<br />

<br />

public ObjectInputStream(InputStream <strong>in</strong>) throws IOException,<br />

StreamCorruptedException<br />

><br />

public f<strong>in</strong>al Object readObject() throws OptionalDataException<br />

ClassNotFoundException, IOException<br />

// Liest e<strong>in</strong> Objekt und gibt es zurück<br />

public boolean readBoolean() throws IOException<br />

public byte readByte(i) throws IOException<br />

public short readShort() throws IOException<br />

public char readChar() throws IOException<br />

public <strong>in</strong>t readInt() throws IOException<br />

public long readLong() throws IOException<br />

public float readFloat() throws IOException<br />

public double readDouble() throws IOException<br />

. ...<br />

Abb.: Die Klasse ObjectInputStream<br />

Analog zum Interface ObjectOutput gibt es hier das Interface ObjectInput<br />

(<strong>in</strong>terface java.io.ObjectInput extends DataInput)<br />

494

Hurra! Ihre Datei wurde hochgeladen und ist bereit für die Veröffentlichung.

Erfolgreich gespeichert!

Leider ist etwas schief gelaufen!