mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2024-12-22 04:57:56 +01:00
ProxyOutputStream: Extend OutputStream
This commit is contained in:
parent
edef899074
commit
41acdfe03a
1 changed files with 6 additions and 6 deletions
|
@ -15,7 +15,7 @@ import java.io.OutputStream
|
||||||
* class is useful if we need to provide an [OutputStream] at one point in time when the final
|
* class is useful if we need to provide an [OutputStream] at one point in time when the final
|
||||||
* target output stream is not yet known.
|
* target output stream is not yet known.
|
||||||
*/
|
*/
|
||||||
class ProxyOutputStream {
|
class ProxyOutputStream : OutputStream() {
|
||||||
private val buffer = ByteArrayOutputStream()
|
private val buffer = ByteArrayOutputStream()
|
||||||
private var swapped: OutputStream? = null
|
private var swapped: OutputStream? = null
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ class ProxyOutputStream {
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
@Throws(IOException::class)
|
@Throws(IOException::class)
|
||||||
fun write(b: ByteArray) {
|
override fun write(b: ByteArray) {
|
||||||
if (swapped == null) {
|
if (swapped == null) {
|
||||||
buffer.write(b)
|
buffer.write(b)
|
||||||
} else {
|
} else {
|
||||||
|
@ -37,7 +37,7 @@ class ProxyOutputStream {
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
@Throws(IOException::class)
|
@Throws(IOException::class)
|
||||||
fun write(b: ByteArray, off: Int, len: Int) {
|
override fun write(b: ByteArray, off: Int, len: Int) {
|
||||||
if (swapped == null) {
|
if (swapped == null) {
|
||||||
buffer.write(b, off, len)
|
buffer.write(b, off, len)
|
||||||
} else {
|
} else {
|
||||||
|
@ -47,7 +47,7 @@ class ProxyOutputStream {
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
@Throws(IOException::class)
|
@Throws(IOException::class)
|
||||||
fun flush() {
|
override fun flush() {
|
||||||
buffer.flush()
|
buffer.flush()
|
||||||
if (swapped != null) {
|
if (swapped != null) {
|
||||||
swapped!!.flush()
|
swapped!!.flush()
|
||||||
|
@ -56,7 +56,7 @@ class ProxyOutputStream {
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
@Throws(IOException::class)
|
@Throws(IOException::class)
|
||||||
fun close() {
|
override fun close() {
|
||||||
buffer.close()
|
buffer.close()
|
||||||
if (swapped != null) {
|
if (swapped != null) {
|
||||||
swapped!!.close()
|
swapped!!.close()
|
||||||
|
@ -65,7 +65,7 @@ class ProxyOutputStream {
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
@Throws(IOException::class)
|
@Throws(IOException::class)
|
||||||
fun write(i: Int) {
|
override fun write(i: Int) {
|
||||||
if (swapped == null) {
|
if (swapped == null) {
|
||||||
buffer.write(i)
|
buffer.write(i)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue