aboutsummaryrefslogtreecommitdiff
path: root/src/jar/net/network/server_output_stream.md
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-03-18 18:54:41 -0700
committerFuwn <[email protected]>2021-03-18 18:54:41 -0700
commitbc59a4b91b4f457f30356f31ad1a636774411470 (patch)
treeec44109b9c72590e85d8d27750fe9cf6fa0de9b6 /src/jar/net/network/server_output_stream.md
parentchore: create contribution guidelines (diff)
downloadbook-bc59a4b91b4f457f30356f31ad1a636774411470.tar.xz
book-bc59a4b91b4f457f30356f31ad1a636774411470.zip
feat: many new pages
Diffstat (limited to 'src/jar/net/network/server_output_stream.md')
-rw-r--r--src/jar/net/network/server_output_stream.md108
1 files changed, 108 insertions, 0 deletions
diff --git a/src/jar/net/network/server_output_stream.md b/src/jar/net/network/server_output_stream.md
new file mode 100644
index 0000000..9999529
--- /dev/null
+++ b/src/jar/net/network/server_output_stream.md
@@ -0,0 +1,108 @@
+# ServerOutputStream
+
+## Imports
+- `java.io.FilterOutputStream`
+- `java.io.IOException`
+- `java.io.OutputStream`
+
+## Extends
+[FilterOutputStream](https://docs.oracle.com/javase/7/docs/api/java/io/FilterOutputStream.html)
+
+## Fields
+### `private int _version`
+Purpose is to be determined.
+
+## Constructors
+```java
+public ServerOutputStream(OutputStream o) {
+ super(o);
+ setVersion(24);
+}
+
+public ServerOutputStream(OutputStream o, int vers) {
+ super(o);
+ setVersion(vers);
+}
+```
+
+## Methods
+### `public void setVersion(int vers)`
+Sets [`this._version`](#private-int-_version) to `vers`.
+
+### `public int getVersion()`
+Returns [`this._version`](#private-int-_version).
+
+### `public final void write(int b) throws IOException`
+Writes the singular byte; `b` to the output stream.
+
+```java
+this.out.write(b);
+```
+
+### `public final void write(byte[] b, int off, len) throws IOException`
+Writes `len` bytes from the specified byte array starting at the offset; `off` to the output stream.
+
+```java
+this.out.write(b, off, len);
+```
+
+### `public final void writeByte(int v) throws IOException`
+Clone of [`write(int b)`](#writeint-b).
+
+### `public final void writeShort(int v) throws IOException`
+```java
+OutputStream out = this.out;
+out.write(v >>> 8 & 0xFF);
+out.write(v >>> 0 & 0xFF);
+```
+
+### `public final void writeInt(int v) throws IOException`
+```java
+OutputStream out = this.out;
+out.write(v >>> 24 & 0xFF);
+out.write(v >>> 16 & 0xFF);
+out.write(v >>> 8 & 0xFF);
+out.write(v >>> 0 & 0xFF);
+```
+
+### `public final void utfLength(String str)`
+```java
+int strlen = str.length();
+int utflen = 0;
+for (int i = 0; i < strlen; i++) {
+ int c = str.charAt(i);
+ if (c >= 1 && c <= 127) {
+ utflen++;
+ } else if (c > 2047) {
+ utflen += 3;
+ } else {
+ utflen += 2;
+ }
+}
+return utflen;
+```
+
+### `public final void writeUTF(String str) throws IOException`
+```java
+OutputStream out = this.out;
+int strlen = str.length();
+int utflen = utfLength(str);
+assert utflen < 256;
+out.write(utflen >>> 0 & 0xFF);
+for (int i = 0; i < strlen; i++) {
+ int c = str.charAt(i);
+ if (c >= 1 && c <= 127) {
+ out.write(c);
+ } else if (c > 2047) {
+ out.write(0xE0 | c >> 12 & 0xF);
+ out.write(0x80 | c >> 6 & 0x3F);
+ out.write(0x80 | c >> 0 & 0x3F);
+ } else {
+ out.write(0xC0 | c >> 6 & 0x1F);
+ out.write(0x80 | c >> 0 & 0x3F);
+ }
+}
+```
+
+### Resources
+- [https://docs.oracle.com/javase/7/docs/api/java/io/FilterOutputStream.html](https://docs.oracle.com/javase/7/docs/api/java/io/FilterOutputStream.html)