本文整理汇总了Java中java.io.ObjectOutput.close方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectOutput.close方法的具体用法?Java ObjectOutput.close怎么用?Java ObjectOutput.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.ObjectOutput
的用法示例。
在下文中一共展示了ObjectOutput.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSerialization
import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
* Serialize an instance, restore it, and check for equality.
*/
public void testSerialization() {
Vector v1 = new Vector(1.0, 2.0);
Vector v2 = null;
try {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(v1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
v2 = (Vector) in.readObject();
in.close();
}
catch (Exception e) {
e.printStackTrace();
}
assertEquals(v1, v2);
}
示例2: testSerialization
import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
* Serialize an instance, restore it, and check for equality.
*/
public void testSerialization() {
DialPlot p1 = new DialPlot();
DialPlot p2 = null;
try {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(p1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
p2 = (DialPlot) in.readObject();
in.close();
}
catch (Exception e) {
e.printStackTrace();
}
assertEquals(p1, p2);
}
示例3: storePrefs
import java.io.ObjectOutput; //导入方法依赖的package包/类
void storePrefs() {
try {
// Serialize to a byte array
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
final ObjectOutput oos = new ObjectOutputStream(bos);
final Object[] hps = this.toArray();
oos.writeObject(hps);
oos.close();
// Get the bytes of the serialized object
final byte[] buf = bos.toByteArray();
getPrefs().putByteArray("HotPixelFilter.HotPixelSet", buf);
}
catch (final Exception e) {
e.printStackTrace();
}
}
示例4: testSerialization
import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
* Serialize an instance, restore it, and check for equality.
*/
public void testSerialization() {
VectorSeries s1 = new VectorSeries("s1");
s1.add(1.0, 0.5, 1.5, 2.0);
VectorSeries s2 = null;
try {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(s1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
s2 = (VectorSeries) in.readObject();
in.close();
}
catch (Exception e) {
e.printStackTrace();
}
assertEquals(s1, s2);
}
示例5: putChipClassPrefs
import java.io.ObjectOutput; //导入方法依赖的package包/类
private void putChipClassPrefs() {
try {
// Serialize to a byte array
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(bos);
out.writeObject(chipClassNames);
out.close();
// Get the bytes of the serialized object
byte[] buf = bos.toByteArray();
prefs.putByteArray("chipClassNames", buf);
} catch (IOException e) {
e.printStackTrace();
} catch (IllegalArgumentException e2) {
log.warning("too many classes in Preferences, " + chipClassNames.size() + " class names");
}
}
示例6: testSerialization
import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
* Serialize an instance, restore it, and check for equality.
*/
public void testSerialization() {
StandardDialFrame f1 = new StandardDialFrame();
StandardDialFrame f2 = null;
try {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(f1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
f2 = (StandardDialFrame) in.readObject();
in.close();
}
catch (Exception e) {
e.printStackTrace();
}
assertEquals(f1, f2);
}
示例7: putArray
import java.io.ObjectOutput; //导入方法依赖的package包/类
private void putArray(int[] array, String key) {
if ((array == null) || (key == null)) {
log.warning("null array or key");
return;
}
try {
// Serialize to a byte array
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(bos);
out.writeObject(array);
out.close();
// Get the bytes of the serialized object
byte[] buf = bos.toByteArray();
getPrefs().putByteArray(key, buf);
} catch (Exception e) {
log.warning(e.toString());
}
}
示例8: testSerialization
import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
* Serialize an instance, restore it, and check for equality.
*/
public void testSerialization() {
SignalRenderer r1 = new SignalRenderer();
SignalRenderer r2 = null;
try {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
r2 = (SignalRenderer) in.readObject();
in.close();
}
catch (Exception e) {
System.out.println(e.toString());
}
assertEquals(r1, r2);
}
示例9: testSerialization
import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
* Serialize an instance, restore it, and check for equality.
*/
public void testSerialization() {
String[] tickLabels = new String[] {"One", "Two", "Three"};
SymbolicAxis a1 = new SymbolicAxis("Test Axis", tickLabels);
SymbolicAxis a2 = null;
try {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(a1);
out.close();
ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
a2 = (SymbolicAxis) in.readObject();
in.close();
}
catch (Exception e) {
System.out.println(e.toString());
}
assertEquals(a1, a2);
}
示例10: testSerialization
import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
* Serialize an instance, restore it, and check for equality.
*/
public void testSerialization() {
StandardCategoryLabelGenerator g1 = new StandardCategoryLabelGenerator(
"{2}", DateFormat.getInstance()
);
StandardCategoryLabelGenerator g2 = null;
try {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
g2 = (StandardCategoryLabelGenerator) in.readObject();
in.close();
}
catch (Exception e) {
System.out.println(e.toString());
}
assertEquals(g1, g2);
}
示例11: testSerialization
import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
* Serialize an instance, restore it, and check for equality.
*/
public void testSerialization() {
// test a default instance
DialValueIndicator i1 = new DialValueIndicator(0, "Label");
DialValueIndicator i2 = null;
try {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(i1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
i2 = (DialValueIndicator) in.readObject();
in.close();
}
catch (Exception e) {
e.printStackTrace();
}
assertEquals(i1, i2);
// test a custom instance
}
示例12: testSerialization
import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
* Serialize an instance, restore it, and check for equality.
*/
public void testSerialization() {
StandardPieItemLabelGenerator g1 = new StandardPieItemLabelGenerator();
StandardPieItemLabelGenerator g2 = null;
try {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
g2 = (StandardPieItemLabelGenerator) in.readObject();
in.close();
}
catch (Exception e) {
System.out.println(e.toString());
}
assertEquals(g1, g2);
}
示例13: testSerialization
import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
* Serialize an instance, restore it, and check for equality.
*/
public void testSerialization() {
IntervalCategoryLabelGenerator g1
= new IntervalCategoryLabelGenerator("{3} - {4}", DateFormat.getInstance());
IntervalCategoryLabelGenerator g2 = null;
try {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
g2 = (IntervalCategoryLabelGenerator) in.readObject();
in.close();
}
catch (Exception e) {
System.out.println(e.toString());
}
assertEquals(g1, g2);
}
示例14: testSerialization
import java.io.ObjectOutput; //导入方法依赖的package包/类
/**
* Serialize an instance, restore it, and check for equality.
*/
public void testSerialization() {
VectorSeries s1 = new VectorSeries("Series");
s1.add(1.0, 1.1, 1.2, 1.3);
VectorSeriesCollection c1 = new VectorSeriesCollection();
c1.addSeries(s1);
VectorSeriesCollection c2 = null;
try {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(c1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
c2 = (VectorSeriesCollection) in.readObject();
in.close();
}
catch (Exception e) {
e.printStackTrace();
}
assertEquals(c1, c2);
}
示例15: close
import java.io.ObjectOutput; //导入方法依赖的package包/类
public static void close(ObjectOutput closeable) {
if (closeable != null) {
try {
closeable.close();
} catch (Exception e) {
//can be ignored
Log.e("IOUtils", e.getMessage());
}
}
}