当前位置: 首页>>代码示例>>Java>>正文


Java SerializeWriter.close方法代码示例

本文整理汇总了Java中com.alibaba.fastjson.serializer.SerializeWriter.close方法的典型用法代码示例。如果您正苦于以下问题:Java SerializeWriter.close方法的具体用法?Java SerializeWriter.close怎么用?Java SerializeWriter.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.alibaba.fastjson.serializer.SerializeWriter的用法示例。


在下文中一共展示了SerializeWriter.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toJSONBytes

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public static final byte[] toJSONBytes(Object object, SerializeConfig config, SerializerFeature... features) {
    SerializeWriter out = new SerializeWriter();

    try {
        JSONSerializer serializer = new JSONSerializer(out, config);
        for (com.alibaba.fastjson.serializer.SerializerFeature feature : features) {
            serializer.config(feature, true);
        }

        serializer.write(object);

        return out.toBytes("UTF-8");
    } finally {
        out.close();
    }
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:17,代码来源:JSON.java

示例2: toJSONStringWithDateFormat

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public static final String toJSONStringWithDateFormat(Object object, String dateFormat, SerializerFeature... features) {
    SerializeWriter out = new SerializeWriter();
    try {
        JSONSerializer serializer = new JSONSerializer(out);
        for (SerializerFeature feature : features) {
            serializer.config(feature, true);
        }
        serializer.config(SerializerFeature.WriteDateUseDateFormat, true);
        if (dateFormat != null) {
            serializer.setDateFormat(dateFormat);
        }
        serializer.write(object);
        String serializeWriter = out.toString();
        return serializeWriter;
    } finally {
        out.close();
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:19,代码来源:JSON.java

示例3: test_erro_0

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_erro_0() throws Exception {
    SerializeWriter out = new SerializeWriter();
    Exception error = null;
    try {
        out.write(new char[0], -1, 0);
    } catch (Exception ex) {
        error = ex;
    }
    Assert.assertNotNull(error);
    out.close();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:SerializeWriterTest_10.java

示例4: test_erro_0

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_erro_0() throws Exception {
    SerializeWriter out = new SerializeWriter(new ErrorWriter());
    Exception error = null;
    try {
        out.flush();
    } catch (Exception ex) {
        error = ex;
    }
    Assert.assertNotNull(error);
    out.close();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:SerializeWriterTest_12.java

示例5: test_error

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_error() throws Exception {
    SerializeWriter writer = new SerializeWriter(new StringWriter());
    Exception error = null;
    try {
        writer.writeTo(new StringWriter());
    } catch (Exception ex) {
        error = ex;
    }
    Assert.assertNotNull(error);
    writer.close();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:SerializeWriterTest_9.java

示例6: test_0

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_0() throws Exception {
    StringWriter out = new StringWriter();
    
    SerializeWriter writer = new SerializeWriter(out, 10);
    Assert.assertEquals(10, writer.getBufferLength());
    
    writer.config(SerializerFeature.QuoteFieldNames, true);
    writer.writeFieldValue(',', "abcde01245abcde", true);
    writer.close();
    
    String text = out.toString();
    Assert.assertEquals(",\"abcde01245abcde\":true", text);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:StreamWriterTest_writeFieldValue.java

示例7: test_0

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_0() throws Exception {
    StringWriter out = new StringWriter();
    
    SerializeWriter writer = new SerializeWriter(out, 10);
    Assert.assertEquals(10, writer.getBufferLength());
    
    writer.writeFieldValue(',', "abcde01245abcde", true);
    writer.close();
    
    String text = out.toString();
    Assert.assertEquals(",abcde01245abcde:true", text);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:StreamWriterTest_writeFieldValue_bool.java

示例8: test_0

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_0() throws Exception {
    StringWriter out = new StringWriter();
    
    SerializeWriter writer = new SerializeWriter(out, 10);
    Assert.assertEquals(10, writer.getBufferLength());
    
    writer.write("abcde");
    writer.writeInt(12345678);
    writer.close();
    
    String text = out.toString();
    Assert.assertEquals("abcde12345678", text);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:StreamWriterTest_writeInt.java

示例9: test_0

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_0() throws Exception {
    StringWriter out = new StringWriter();
    
    SerializeWriter writer = new SerializeWriter(out, 10);
    Assert.assertEquals(10, writer.getBufferLength());
    
    writer.writeString("abcde12345678\"\\");
    writer.close();
    
    String text = out.toString();
    Assert.assertEquals("\"abcde12345678\\\"\\\\\"", text);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:StreamWriterTest_writeValueString2.java

示例10: toJSONStringZ

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public static final String toJSONStringZ(Object object, SerializeConfig mapping, SerializerFeature... features) {
    SerializeWriter out = new SerializeWriter(features);
    try {
        new JSONSerializer(out, mapping).write(object);
        String serializeWriter = out.toString();
        return serializeWriter;
    } finally {
        out.close();
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:11,代码来源:JSON.java

示例11: test_writer_1

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
public void test_writer_1() throws Exception {
    StringWriter strOut = new StringWriter();
    SerializeWriter out = new SerializeWriter(strOut, 1);

    try {
        JSONSerializer serializer = new JSONSerializer(out);

        Map map = Collections.singletonMap("", "a");
        serializer.write(map);
    } finally {
        out.close();
    }
    Assert.assertEquals("{\"\":\"a\"}", strOut.toString());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:SerializeWriterTest_14.java

示例12: test_0

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_0() throws Exception {
    StringWriter out = new StringWriter();
    
    byte[] bytes = "民主共和君主宪".getBytes("GB2312");
    SerializeWriter writer = new SerializeWriter(out, 10);
    Assert.assertEquals(10, writer.getBufferLength());
    
    writer.writeByteArray(bytes);
    writer.close();
    
    String text = out.toString();
    byte[] result = JSON.parseObject(text, byte[].class);
    Assert.assertEquals("民主共和君主宪", new String(result, "GB2312"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:StreamWriterTest_writeBytes1.java

示例13: test_0

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_0() throws Exception {
    StringWriter out = new StringWriter();
    
    SerializeWriter writer = new SerializeWriter(out, 10);
    Assert.assertEquals(10, writer.getBufferLength());
    
    writer.write("abcde");
    writer.writeInt(12345678);
    writer.write(',');
    writer.close();
    
    String text = out.toString();
    Assert.assertEquals("abcde12345678,", text);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:StreamWriterTest_writeIntAndChar.java

示例14: test_0

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_0() throws Exception {
    StringWriter out = new StringWriter();
    
    SerializeWriter writer = new SerializeWriter(out, 10);
    writer.config(SerializerFeature.QuoteFieldNames, true);
    Assert.assertEquals(10, writer.getBufferLength());
    
    writer.writeFieldValue(',', "abcde01245abcde", 123);
    writer.close();
    
    String text = out.toString();
    Assert.assertEquals(",\"abcde01245abcde\":123", text);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:StreamWriterTest_writeFieldValue_int.java

示例15: test_0

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_0() throws Exception {
    StringWriter out = new StringWriter();
    
    SerializeWriter writer = new SerializeWriter(out, 10);
    writer.config(SerializerFeature.BrowserCompatible, true);
    Assert.assertEquals(10, writer.getBufferLength());
    
    writer.writeString("abcde12345678\t");
    writer.close();
    
    String text = out.toString();
    Assert.assertEquals("\"abcde12345678\\t\"", text);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:StreamWriterTest_writeValueString1.java


注:本文中的com.alibaba.fastjson.serializer.SerializeWriter.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。