本文整理了Java中java.io.DataOutputStream.close()
方法的一些代码示例,展示了DataOutputStream.close()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DataOutputStream.close()
方法的具体详情如下:
包路径:java.io.DataOutputStream
类名称:DataOutputStream
方法名:close
暂无
代码示例来源:origin: redisson/redisson
private SnappyCodec(byte[] magic, int version, int compatibleVersion)
{
this.magic = magic;
this.version = version;
this.compatibleVersion = compatibleVersion;
ByteArrayOutputStream header = new ByteArrayOutputStream(HEADER_SIZE);
DataOutputStream d = new DataOutputStream(header);
try {
d.write(magic, 0, MAGIC_LEN);
d.writeInt(version);
d.writeInt(compatibleVersion);
d.close();
}
catch (IOException e) {
throw new RuntimeException(e);
}
headerArray = header.toByteArray();
}
代码示例来源:origin: hankcs/HanLP
public void save(String fileName) throws IOException
{
DataOutputStream out = null;
try
{
out = new DataOutputStream(new BufferedOutputStream(
IOUtil.newOutputStream(fileName)));
for (int i = 0; i < size; i++)
{
out.writeInt(base[i]);
out.writeInt(check[i]);
}
out.close();
}
finally
{
if (out != null)
out.close();
}
}
代码示例来源:origin: stanfordnlp/CoreNLP
public static void saveFloatArr(DataOutputStream rf, float[] arr) throws IOException {
rf.writeInt(arr.length);
byte[] lArr = floatArrToByteArr(arr);
rf.write(lArr);
rf.close();
}
代码示例来源:origin: apache/rocketmq
private static String createBodyFile(MessageExt msg) throws IOException {
DataOutputStream dos = null;
try {
String bodyTmpFilePath = "/tmp/rocketmq/msgbodys";
File file = new File(bodyTmpFilePath);
if (!file.exists()) {
file.mkdirs();
}
bodyTmpFilePath = bodyTmpFilePath + "/" + msg.getMsgId();
dos = new DataOutputStream(new FileOutputStream(bodyTmpFilePath));
dos.write(msg.getBody());
return bodyTmpFilePath;
} finally {
if (dos != null)
dos.close();
}
}
代码示例来源:origin: marytts/marytts
public DataOutputStream writeHeader(String file, boolean bLeaveStreamOpen) throws IOException {
DataOutputStream stream = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
if (stream != null) {
writeHeader(stream);
if (!bLeaveStreamOpen) {
stream.close();
stream = null;
}
}
return stream;
}
代码示例来源:origin: pentaho/pentaho-kettle
public static void appendToFile( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
Object FunctionContext ) {
if ( !isNull( ArgList ) && !isUndefined( ArgList ) ) {
try {
FileOutputStream file = new FileOutputStream( (String) ArgList[0], true );
DataOutputStream out = new DataOutputStream( file );
out.writeBytes( (String) ArgList[1] );
out.flush();
out.close();
} catch ( Exception er ) {
throw new RuntimeException( er.toString() );
}
} else {
throw new RuntimeException( "The function call appendToFile requires arguments." );
}
}
代码示例来源:origin: apache/kylin
private <T extends RootPersistentEntity> void saveSystemCubeMetadataToFile(String fileName, T metadata,
Serializer serializer) throws IOException {
ByteArrayOutputStream buf = new ByteArrayOutputStream();
DataOutputStream dout = new DataOutputStream(buf);
serializer.serialize(metadata, dout);
dout.close();
buf.close();
saveToFile(fileName, buf.toString("UTF-8"));
}
代码示例来源:origin: hankcs/HanLP
DataOutputStream out = new DataOutputStream(new FileOutputStream(HanLP.Config.CharTypePath));
for (int[] array : typeList)
out.writeByte(array[2]);
out.close();
ByteArray byteArray = ByteArray.createByteArray(HanLP.Config.CharTypePath);
return byteArray;
代码示例来源:origin: igniterealtime/Smack
/**
* Writes the DiscoverInfo stanza to an file
*
* @param file
* @param info
* @throws IOException
*/
private static void writeInfoToFile(File file, DiscoverInfo info) throws IOException {
DataOutputStream dos = new DataOutputStream(new FileOutputStream(file));
try {
dos.writeUTF(info.toXML(null).toString());
} finally {
dos.close();
}
}
代码示例来源:origin: apache/geode
private DataInput createDIS() throws IOException {
this.dos.close();
ByteArrayInputStream bais = new ByteArrayInputStream(this.baos.toByteArray());
return new DataInputStream(bais);
}
代码示例来源:origin: chentao0707/SimplifyReader
private static void addBodyIfExists(HttpURLConnection connection, Request<?> request)
throws IOException, AuthFailureError {
byte[] body = request.getBody();
if (body != null) {
connection.setDoOutput(true);
connection.addRequestProperty(HEADER_CONTENT_TYPE, request.getBodyContentType());
DataOutputStream out = new DataOutputStream(connection.getOutputStream());
out.write(body);
out.close();
}
}
}
代码示例来源:origin: frohoff/ysoserial
dos = new DataOutputStream(os);
dos.writeInt(TransportConstants.Magic);
dos.writeShort(TransportConstants.Version);
dos.writeByte(TransportConstants.SingleOpProtocol);
dos.write(TransportConstants.Call);
dos.close();
代码示例来源:origin: hankcs/HanLP
/**
* 保存dat到磁盘
* @param map
* @return
*/
static boolean saveDat(TreeMap<String, Character> map)
{
try
{
DataOutputStream out = new DataOutputStream(new BufferedOutputStream(IOUtil.newOutputStream(path + Predefine.VALUE_EXT)));
out.writeInt(map.size());
for (Character character : map.values())
{
out.writeChar(character);
}
out.close();
}
catch (Exception e)
{
logger.warning("保存值" + path + Predefine.VALUE_EXT + "失败" + e);
return false;
}
return trie.save(path + Predefine.TRIE_EXT);
}
代码示例来源:origin: hankcs/HanLP
static boolean saveDat(String path, TreeMap<String, String> map)
{
Collection<String> dependencyList = map.values();
// 缓存值文件
try
{
DataOutputStream out = new DataOutputStream(IOUtil.newOutputStream(path + ".bi" + Predefine.BIN_EXT));
out.writeInt(dependencyList.size());
for (String dependency : dependencyList)
{
out.writeUTF(dependency);
}
if (!trie.save(out)) return false;
out.close();
}
catch (Exception e)
{
logger.warning("保存失败" + e);
return false;
}
return true;
}
代码示例来源:origin: skylot/jadx
public void test(OutputStream output) throws IOException {
DataOutputStream out = new DataOutputStream(output);
try {
out.writeByte(1);
out.writeInt(classes.length);
for (NClass cls : classes) {
writeString(out, cls.getName());
}
for (NClass cls : classes) {
NClass[] parents = cls.getParents();
out.writeByte(parents.length);
for (NClass parent : parents) {
out.writeInt(parent.getId());
}
}
} finally {
out.close();
}
}
代码示例来源:origin: hankcs/HanLP
/**
* 保存到路径
*
* @param modelFile
* @throws IOException
*/
public void save(String modelFile) throws IOException
{
DataOutputStream out = new DataOutputStream(new BufferedOutputStream(IOUtil.newOutputStream(modelFile)));
save(out);
out.close();
}
代码示例来源:origin: aws/aws-sdk-java
private byte[] getPrelude(int totalLength) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream(8);
DataOutputStream dos = new DataOutputStream(baos);
int headerLength = totalLength - Message.MESSAGE_OVERHEAD - payload.length;
dos.writeInt(totalLength);
dos.writeInt(headerLength);
dos.close();
return baos.toByteArray();
}
代码示例来源:origin: apache/rocketmq
private static String createBodyFile(MessageExt msg) throws IOException {
DataOutputStream dos = null;
try {
String bodyTmpFilePath = "/tmp/rocketmq/msgbodys";
File file = new File(bodyTmpFilePath);
if (!file.exists()) {
file.mkdirs();
}
bodyTmpFilePath = bodyTmpFilePath + "/" + msg.getMsgId();
dos = new DataOutputStream(new FileOutputStream(bodyTmpFilePath));
dos.write(msg.getBody());
return bodyTmpFilePath;
} finally {
if (dos != null)
dos.close();
}
}
代码示例来源:origin: marytts/marytts
public DataOutputStream writeHeader(String file, boolean bLeaveStreamOpen) throws IOException {
DataOutputStream stream = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
if (stream != null) {
writeHeader(stream);
if (!bLeaveStreamOpen) {
stream.close();
stream = null;
}
}
return stream;
}
代码示例来源:origin: apache/flink
private FileInputSplit createTempDeflateFile(String content) throws IOException {
File tempFile = File.createTempFile("test_contents", "tmp.deflate");
tempFile.deleteOnExit();
DataOutputStream dos = new DataOutputStream(new DeflaterOutputStream(new FileOutputStream(tempFile)));
dos.writeBytes(content);
dos.close();
return new FileInputSplit(0, new Path(tempFile.toURI().toString()), 0, tempFile.length(), new String[] {"localhost"});
}
内容来源于网络,如有侵权,请联系作者删除!