Code example for DataOutputStream

Methods: writeBoolean, writeInt

0
			} 
		} 
		 
		public boolean write(boolean value) {
			try { 
				dataOutputStream.writeBoolean(value);
				return value;
			} catch (IOException e) {
				throw new RuntimeException();
			} 
		} 
		 
		public void write(int value) {
			try { 
				dataOutputStream.writeInt(value);
			} catch (IOException e) {
				throw new RuntimeException();
			}			 
		} 
 
		public void write(long value) {
			try { 
				dataOutputStream.writeLong(value);
			} catch (IOException e) {
				throw new RuntimeException();
			} 
		} 
 
		public void write(double value) {
			try { 
				dataOutputStream.writeDouble(value);
			} catch (IOException e) {
				throw new RuntimeException();
			} 
		} 
 
		public void write(byte[] value) {
			try { 
				dataOutputStream.writeInt(value.length);
				dataOutputStream.write(value);
			} catch (IOException e) {
				throw new RuntimeException();
			} 
		} 
 
		public void write(String value) {
			try { 
				Integer index = stringMap.get(value);
				if (index == null) {
					dataOutputStream.writeBoolean(true);
					dataOutputStream.writeUTF(value);
					stringMap.put(value, stringMap.size());
				} 
				else { 
					dataOutputStream.writeBoolean(false);
					dataOutputStream.writeInt(index);
				} 
			} catch (IOException e) {
				throw new RuntimeException();
			} 
		} 
 
		public void write(Bitmap value, int flags) {
			try { 
				write(value != null);
				if (value != null) {
					Integer index = bmpMap.get(value);
					if (index == null) {
						dataOutputStream.writeBoolean(true);
						if (value.compress(CompressFormat.PNG, 100, dataOutputStream) == false)
							throw new RuntimeException();
						bmpMap.put(value, bmpMap.size());
					} 
					else { 
						dataOutputStream.writeBoolean(false);
						dataOutputStream.writeInt(index);
					} 
				} 
			} catch (IOException e) {
				throw new RuntimeException();
			}