Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Binär Datei schreiben

Empfohlene Antworten

Veröffentlicht

Hallo,

Ich möchte eine Binär Datei schreiben.

Aber es soll nur das in der Datei stehen was ich wirklich schreibe.

Also wenn ich ne 10 schreiben will soll am ende auch nur die 10 in der datei zu sehen sein wenn ich mir es angucke.

	  static void serialize( String filename )

	  {

	    try

	    {

	      FileOutputStream file = new FileOutputStream( filename );

	      ObjectOutputStream o = new ObjectOutputStream( file );

	          o.write  ( 10 );

	      o.close();



	    }

	    catch ( IOException e ) 

	    { 

	    	System.err.println( e ); 

	    }

	  }

Das ist mein Code um die 10 in die Datei zu schreiben. Meiner meinung anch müsste doch nun in Hex 0A in der Datei stehen und mehr nicht. Folgendes steht nun aber in meiner Datei
ac ed 00 05 77 01 0a

Kennt jemand eine Möglichkeit wie ich sonst noch Binär Datein schreiben könnte?

ohne das irgendwelche zusätze in der Datei stehen??

glaube das Problem gelöst zu haben...

Hab es jetzt folgendermaßen gemacht:

	    	FileOutputStream f = new FileOutputStream(filename);

	    	DataOutputStream out = new DataOutputStream(f);

	    	out.writeByte(10);

	    	out.close();

funktioniert wunderbar =) ausgabe in der Datei in Hex
0a

MFG

Wollte grad schreiben...

ObjectOutputStream gibt ja schließlich auch mit um welche Art von Object es sich handelt.

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.