MCBBS Wiki欢迎您共同参与编辑!在参与编辑之前请先阅读Wiki方针

如果在编辑的过程中遇到了什么问题,可以去讨论板提问。

为了您能够无阻碍地参与编辑 未验证/绑定过邮箱的用户,请尽快绑定/验证

MCBBS Wiki GitHub群组已上线!

您可以在回声洞中发表吐槽!

服务器状态监控。点击进入

本站由MCBBS用户自行搭建,与MCBBS及东银河系漫游指南(北京)科技有限公司没有从属关系。点此了解 MCBBS Wiki 不是什么>>

用户:洞穴夜莺/EInputStream:修订间差异

来自MCBBS Wiki
跳到导航 跳到搜索
无编辑摘要
(洞穴夜莺移动页面用户:洞穴夜莺用户:洞穴夜莺/EInputStream
 
(未显示同一用户的4个中间版本)
第2行: 第2行:
{{eee}}
{{eee}}


<pre>
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;


<div><div style="height: 30px; background-color: #4e5254; width: 110px; color: #bbbbbb; padding: 0px 10px; position: relative;">EInputStream.java<div style="position: absolute;left: 0px;right: 0px;bottom: 0px;top: 25px;background: #747a80; font-family: mono;"></div></div>
/**
<div style="white-space: pre; background-color: #2b2b2b; color: #a9b7c6; margin-top: -10px; font-family: mono;"><div style="margin: 10px;">
<span style="color: #cc7832;">import</span> java.io.IOException<span style="color: #cc7832;">;</span>
<span style="color: #cc7832;">import</span> java.io.InputStream<span style="color: #cc7832;">;</span>
<span style="color: #cc7832;">import</span> java.io.OutputStream<span style="color: #cc7832;">;</span>

<span style="color: #629755;"><nowiki>/**
* You can read nothing but infinite 'e' from an EInputStream
* You can read nothing but infinite 'e' from an EInputStream
* Example:
* @author CaveNightingale
* new EInputStream().transferTo(stdout);
*/
* </nowiki><b><u>@author</u></b><nowiki> CaveNightingale
public class EInputStream extends InputStream {
*/</nowiki></span>
private static final byte[] BUFFER = new byte[8192];
<span style="color: #cc7832;">public class</span> EInputStream <span style="color: #cc7832;">extends</span> InputStream {
static {
<nowiki> </nowiki><span style="color: #cc7832;">private static final byte</span>[] <span style="color: #9876aa;">BUFFER</span> = <span style="color: #cc7832;">new byte</span>[<span style="color: #5d8bb9;">8192</span>]<span style="color: #cc7832;">;</span>
for(int i = 0; i < BUFFER.length; i++)
<nowiki> </nowiki><span style="color: #cc7832;">static</span> {
BUFFER[i] = (byte)'e';
<nowiki> </nowiki><span style="color: #cc7832;">for</span>(<span style="color: #cc7832;">int</span> i = <span style="color: #5d8bb9;">0</span><span style="color: #cc7832;">;</span> i < <span style="color: #9876aa;">BUFFER</span>.<span style="color: #9876aa;">length</span><span style="color: #cc7832;">;</span> i++)
}
<nowiki> </nowiki><span style="color: #9876aa;">BUFFER</span>[i] = (<span style="color: #cc7832;">byte</span>)<span style="color: #6a8759;">'e'</span><span style="color: #cc7832;">;</span>
<nowiki> </nowiki>}


<nowiki> </nowiki><span style="color: #bbb12a;">@Override</span>
@Override
public int read() {
<nowiki> </nowiki><span style="color: #cc7832;">public int</span> <span style="color: #ffc56a;">read</span>() {
<nowiki> </nowiki><span style="color: #cc7832;">return</span> <span style="color: #6a8759;">'e'</span><span style="color: #cc7832;">;</span>
return 'e';
}
<nowiki> </nowiki>}


<nowiki> </nowiki><span style="color: #bbb12a;">@Override</span>
@Override
<nowiki> </nowiki><span style="color: #cc7832;">public int</span> <span style="color: #ffc56a;">read</span>(<span style="color: #cc7832;">byte</span>[] b) {
public int read(byte[] b) {
<nowiki> </nowiki><span style="color: #cc7832;">for</span>(<span style="color: #cc7832;">int</span> i = <span style="color: #5d8bb9;">0</span>; i < b.<span style="color: #9876aa;">length</span>; i++)
for(int i = 0; i < b.length; i++)
<nowiki> </nowiki>b[i] = (<span style="color: #cc7832;">byte</span>)<span style="color: #5d8bb9;">'e'</span><span style="color: #cc7832;">;</span>
b[i] = (byte)'e';
return b.length;
<nowiki> </nowiki>return b.<span style="color: #9876aa;">length</span><span style="color: #cc7832;">;</span>
}
<nowiki> </nowiki>}


<nowiki> </nowiki><span style="color: #bbb12a;">@Override</span>
@Override
public byte[] readAllBytes() {
<nowiki> </nowiki><span style="color: #cc7832;">public byte</span>[] <span style="color: #ffc56a;">readAllBytes</span>() {
throw new OutOfMemoryError("Endless");
<nowiki> </nowiki><span style="color: #cc7832;">throw new</span> OutOfMemoryError(<span style="color: #6a8759;">"Endless"</span>)<span style="color: #cc7832;">;</span>
}
<nowiki> </nowiki>}


<nowiki> </nowiki><span style="color: #bbb12a;">@Override</span>
@Override
<nowiki> </nowiki><span style="color: #cc7832;">public int</span> <span style="color: #ffc56a;">read</span>(<span style="color: #cc7832;">byte</span>[] b, <span style="color: #cc7832;">int</span> off, <span style="color: #cc7832;">int</span> len) {
public int read(byte[] b, int off, int len) {
for(int i = off; i < len + off; i++)
<nowiki> </nowiki><span style="color: #cc7832;">for</span>(<span style="color: #cc7832;">int</span> i = off<span style="color: #cc7832;">;</span> i < len + off<span style="color: #cc7832;">;</span> i++)
<nowiki> </nowiki>b[i] = (<span style="color: #cc7832;">byte</span>)<span style="color: #6a8759;">'e'</span><span style="color: #cc7832;">;</span>
b[i] = (byte)'e';
<nowiki> </nowiki><span style="color: #cc7832;">return</span> len<span style="color: #cc7832;">;</span>
return len;
}
<nowiki> </nowiki>}


<nowiki> </nowiki><span style="color: #bbb12a;">@Override</span>
@Override
public byte[] readNBytes(int len) {
<nowiki> </nowiki><span style="color: #cc7832;">public byte</span>[] <span style="color: #ffc56a;">readNBytes</span>(<span style="color: #cc7832;">int</span> len) {
byte[] rval = new byte[len];
<nowiki> </nowiki><span style="color: #cc7832;">byte</span>[] rval = <span style="color: #cc7832;">new byte</span>[len]<span style="color: #cc7832;">;</span>
read(rval);
<nowiki> </nowiki>read(rval)<span style="color: #cc7832;">;</span>
<nowiki> </nowiki><span style="color: #cc7832;">return</span> rval<span style="color: #cc7832;">;</span>
return rval;
}
<nowiki> </nowiki>}


<nowiki> </nowiki><span style="color: #bbb12a;">@Override</span>
@Override
public int readNBytes(byte[] b, int off, int len) {
<nowiki> </nowiki><span style="color: #cc7832;">public int</span> <span style="color: #ffc56a;">readNBytes</span>(<span style="color: #cc7832;">byte</span>[] b, <span style="color: #cc7832;">int</span> off, <span style="color: #cc7832;">int</span> len) {
return read(b, off, len);
<nowiki> </nowiki><span style="color: #cc7832;">return</span> read(b, off, len)<span style="color: #cc7832;">;</span>
}
<nowiki> </nowiki>}


<nowiki> </nowiki><span style="color: #bbb12a;">@Override</span>
@Override
<nowiki> </nowiki><span style="color: #cc7832;">public long</span> <span style="color: #ffc56a;">skip</span>(<span style="color: #cc7832;">long</span> n) {
public long skip(long n) {
<nowiki> </nowiki><span style="color: #cc7832;">return</span> n<span style="color: #cc7832;">;</span>
return n;
}
<nowiki> </nowiki>}


<nowiki> </nowiki><span style="color: #bbb12a;">@Override</span>
@Override
public long transferTo(OutputStream out) throws IOException {
<nowiki> </nowiki><span style="color: #cc7832;">public long</span> <span style="color: #ffc56a;">transferTo</span>(OutputStream out) <span style="color: #cc7832;">throws</span> IOException {
while(true)
<nowiki> </nowiki> while(<span style="color: #cc7832;">true</span>)
out.write(BUFFER);
<nowiki> </nowiki>out.write(<span style="color: #9876aa;">BUFFER</span>)<span style="color: #cc7832;">;</span>
}
<nowiki> </nowiki>}
}</pre>
}</div></div></div>

2021年7月19日 (一) 10:22的最新版本

这个用户就是洞穴夜莺

eee

当你开始eee的时候,别人也在回复你eee。本条目经过e 道 阳 光认可,适合热衷作死eee的用户阅读。在eee前,请您eee

  • 务必遵守论坛规章制度,这种行为可能招致您被MCBBS管理人员警告乃至封禁!
  • 切勿eee过度,过度eee是违规行为,且可能会招致别人eee乃至91.35W个e
  • 不信e不传e


EInputStream.java

import java.io.IOException; import java.io.InputStream; import java.io.OutputStream;

/** * You can read nothing but infinite 'e' from an EInputStream * Example: * new EInputStream().transferTo(stdout); * @author CaveNightingale */ public class EInputStream extends InputStream { private static final byte[] BUFFER = new byte[8192]; static { for(int i = 0; i < BUFFER.length; i++) BUFFER[i] = (byte)'e'; }

@Override public int read() { return 'e'; }

@Override public int read(byte[] b) { for(int i = 0; i < b.length; i++) b[i] = (byte)'e'; return b.length; }

@Override public byte[] readAllBytes() { throw new OutOfMemoryError("Endless"); }

@Override public int read(byte[] b, int off, int len) { for(int i = off; i < len + off; i++) b[i] = (byte)'e'; return len; }

@Override public byte[] readNBytes(int len) { byte[] rval = new byte[len]; read(rval); return rval; }

@Override public int readNBytes(byte[] b, int off, int len) { return read(b, off, len); }

@Override public long skip(long n) { return n; }

@Override public long transferTo(OutputStream out) throws IOException { while(true) out.write(BUFFER); }

}