forked from txs72/JavaTutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestObjectStreamForArray.java
More file actions
executable file
·43 lines (40 loc) · 1.39 KB
/
TestObjectStreamForArray.java
File metadata and controls
executable file
·43 lines (40 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* */ package ch17;
/* */ import java.io.*;
/* */
/* */
/* */
/* */ public class TestObjectStreamForArray {
/* */ public static void main(String[] args) throws ClassNotFoundException, IOException {
/* 8 */ int[] numbers = { 1, 2, 3, 4, 5 };
/* 9 */ String[] strings = { "John", "Susan", "Kim" };
/* */
/* */
/* 12 */ try (ObjectOutputStream output = new ObjectOutputStream(new FileOutputStream("array.dat", true))) {
/* */
/* */
/* */
/* 16 */ output.writeObject(numbers);
/* 17 */ output.writeObject(strings);
/* */ }
/* */
/* */
/* 21 */ try (ObjectInputStream input = new ObjectInputStream(new FileInputStream("array.dat"))) {
/* */
/* */
/* 24 */ int[] newNumbers = (int[])input.readObject();
/* 25 */ String[] newStrings = (String[])input.readObject();
/* */
/* */ int i;
/* 28 */ for (i = 0; i < newNumbers.length; i++)
/* 29 */ System.out.print(newNumbers[i] + " ");
/* 30 */ System.out.println();
/* */
/* 32 */ for (i = 0; i < newStrings.length; i++)
/* 33 */ System.out.print(newStrings[i] + " ");
/* */ }
/* */ }
/* */ }
/* Location: /Volumes/TXS.128G/hope useful/practice/2020.jar!/ch17/TestObjectStreamForArray.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/