📄 opstream.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: OpStream.java
package carven;
import java.io.InputStream;
import com.flying.common.logger.Log4j;
public class OpStream
{
public OpStream()
{
}
public static String ReadLine(InputStream inStream)
throws Exception
{
byte result[] = new byte[5000];
int i = 0;
for (byte tmp[] = new byte[1]; inStream.read(tmp) > -1;)
{
result[i] = tmp[0];
i++;
if (tmp[0] == 10)
return new String(result, 0, i - 2);
}
return new String(result, 0, i);
}
public static boolean AvailStream(InputStream inStream, int timeout, int interval, int requireLen)
throws Exception
{
int count = timeout / interval;
for (int i = 0; i < count; i++)
{
if (inStream.available() >= requireLen)
return true;
Thread.sleep(interval);
}
return false;
}
public static boolean AvailStream(InputStream inStream, int timeout, int interval)
throws Exception
{
int count = timeout / interval;
int requireLen = 0;
for (int i = 0; i < count; i++)
{
if (inStream.available() > requireLen)
return true;
Thread.sleep(interval);
}
return false;
}
public static byte[] ReadBytes(InputStream inStream, int bytesNum)
throws Exception
{
if (bytesNum <= 0)
return null;
byte result[] = new byte[bytesNum];
if (!AvailStream(inStream, 20000, 10))
{
throw new Exception("read byte from stream timeout.");
//inStream.close();
}
int readNum = inStream.read(result);
System.out.println("************realGetln:"+readNum);
if (readNum < bytesNum)
{
System.out.println("readNum < bytesNum:"+readNum +"<"+ bytesNum);
throw new Exception("read byte from stream wrong,not exact length.");
}
else
return result;
}
public static byte[] ReadBytes(InputStream inStream, int waitTime, int bytesNum) throws Exception
{
if (bytesNum <= 0)
return null;
byte result[] = new byte[bytesNum];
if (!AvailStream(inStream, waitTime, 10))
{
throw new Exception("read byte from stream timeout.");
//inStream.close();
}
int readNum = inStream.read(result);
if (readNum < bytesNum)
throw new Exception("read byte from stream wrong,not exact length.");
else
return result;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -