本文整理匯總了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());
}
}
}