Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/text/Format/NumberFormat/SerializationSaveTest.java
41152 views
1
/*
2
* Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/*
25
* No at-test for this test, because it needs to be run on JDK 1.1.4.
26
* Instead, the resulting serialized files DecimalFormat.114 and
27
* DecimalFormatSymbols.114 are archived.
28
*/
29
30
import java.awt.*;
31
import java.text.*;
32
import java.util.*;
33
import java.io.*;
34
35
public class SerializationSaveTest {
36
37
public static void main(String[] args)
38
{
39
try {
40
CheckDecimalFormat it = new CheckDecimalFormat();
41
System.out.println(it.Update());
42
FileOutputStream ostream = new FileOutputStream("DecimalFormat.114");
43
ObjectOutputStream p = new ObjectOutputStream(ostream);
44
p.writeObject(it);
45
ostream.close();
46
System.out.println("DecimalFormat saved ok.");
47
CheckDecimalFormatSymbols it2 = new CheckDecimalFormatSymbols();
48
System.out.println("getDigit : " + it2.Update());
49
FileOutputStream ostream2 = new FileOutputStream("DecimalFormatSymbols.114");
50
ObjectOutputStream p2 = new ObjectOutputStream(ostream2);
51
p2.writeObject(it2);
52
ostream2.close();
53
System.out.println("DecimalFormatSymbols saved ok.");
54
} catch (Exception e) {
55
e.printStackTrace();
56
}
57
}
58
}
59
60
@SuppressWarnings("serial")
61
class CheckDecimalFormat implements Serializable
62
{
63
DecimalFormat _decFormat = (DecimalFormat)NumberFormat.getInstance();
64
65
public String Update()
66
{
67
Random r = new Random();
68
return _decFormat.format(r.nextDouble());
69
}
70
}
71
72
@SuppressWarnings("serial")
73
class CheckDecimalFormatSymbols implements Serializable
74
{
75
DecimalFormatSymbols _decFormatSymbols = new DecimalFormatSymbols();
76
77
public char Update()
78
{
79
return _decFormatSymbols.getDigit();
80
}
81
}
82
83