import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.sql.Clob;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
* 将输入流写入到输出流当中
* @param is 输入流
* @param os 输出流
* @throws IOException
*/
public static void copyStream( InputStream is, OutputStream os )
throws IOException
{
byte[] data = new byte[4096];
int readed = is.read(data);
while (readed != -1)
{
os.write(data,0,readed);
readed = is.read(data);
}
}
/**
* 通过Clob对象返回字符串
* @param c
* @return
*/
public static String getClobString(Clob c) {
try {
Reader reader=c.getCharacterStream();
if (reader == null) {
return null;
}
StringBuffer sb = new StringBuffer();
char[] charbuf = new char[4096];
for (int i = reader.read(charbuf); i > 0; i = reader.read(charbuf)) {
sb.append(charbuf, 0, i);
}
return sb.toString();
} catch (Exception e) {
return \"\";
}
}
}
本文地址:https://www.stayed.cn/item/6873
转载请注明出处。
本站部分内容来源于网络,如侵犯到您的权益,请 联系我