MCBBS Wiki欢迎您共同参与编辑!在参与编辑之前请先阅读Wiki方针。
如果在编辑的过程中遇到了什么问题,可以去讨论板提问。
为了您能够无阻碍地参与编辑 未验证/绑定过邮箱的用户,请尽快绑定/验证。
MCBBS Wiki GitHub群组已上线!
您可以在回声洞中发表吐槽!
服务器状态监控。点击进入
本站由MCBBS用户自行搭建,与MCBBS及东银河系漫游指南(北京)科技有限公司没有从属关系。点此了解 MCBBS Wiki 不是什么>>
用户:洞穴夜莺/EInputStream:修订间差异
< 用户:洞穴夜莺
(创建页面,内容为“此用户即洞穴夜莺”) |
无编辑摘要 |
||
第1行: | 第1行: | ||
这个用户就是[[洞穴夜莺]] |
|||
{{eee}} |
|||
<pre> |
|||
import java.io.IOException; |
|||
import java.io.InputStream; |
|||
import java.io.OutputStream; |
|||
/** |
|||
* You can read nothing but infinite 'e' from an EInputStream |
|||
* @author CaveNightingale |
|||
*/ |
|||
public class EInputStream extends InputStream { |
|||
private static final byte[] BUFFER = new byte[2048]; |
|||
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) throws IOException { |
|||
for(int i = 0; i < b.length; i++) |
|||
b[i] = (byte)'e'; |
|||
return b.length; |
|||
} |
|||
@Override |
|||
public byte[] readAllBytes() throws IOException { |
|||
throw new OutOfMemoryError("Endless"); |
|||
} |
|||
@Override |
|||
public int read(byte[] b, int off, int len) throws IOException { |
|||
for(int i = off; i < len + off; i++) |
|||
b[i] = (byte)'e'; |
|||
return len; |
|||
} |
|||
@Override |
|||
public byte[] readNBytes(int len) throws IOException { |
|||
byte[] rval = new byte[len]; |
|||
read(rval); |
|||
return rval; |
|||
} |
|||
@Override |
|||
public int readNBytes(byte[] b, int off, int len) throws IOException { |
|||
return read(b, off, len); |
|||
} |
|||
@Override |
|||
public long skip(long n) throws IOException { |
|||
return n; |
|||
} |
|||
@Override |
|||
public long transferTo(OutputStream out) throws IOException { |
|||
while(true) |
|||
out.write(BUFFER); |
|||
} |
|||
}</pre> |
2020年8月29日 (六) 00:43的版本
这个用户就是洞穴夜莺
import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; /** * You can read nothing but infinite 'e' from an EInputStream * @author CaveNightingale */ public class EInputStream extends InputStream { private static final byte[] BUFFER = new byte[2048]; 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) throws IOException { for(int i = 0; i < b.length; i++) b[i] = (byte)'e'; return b.length; } @Override public byte[] readAllBytes() throws IOException { throw new OutOfMemoryError("Endless"); } @Override public int read(byte[] b, int off, int len) throws IOException { for(int i = off; i < len + off; i++) b[i] = (byte)'e'; return len; } @Override public byte[] readNBytes(int len) throws IOException { byte[] rval = new byte[len]; read(rval); return rval; } @Override public int readNBytes(byte[] b, int off, int len) throws IOException { return read(b, off, len); } @Override public long skip(long n) throws IOException { return n; } @Override public long transferTo(OutputStream out) throws IOException { while(true) out.write(BUFFER); } }