FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaDeserH2HC/TestSerialize.java at master · securityphoenix/JavaDeserH2HC · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
securityphoenix
/
JavaDeserH2HC
Public
forked from
joaomatosf/JavaDeserH2HC
Notifications
You must be signed in to change notification settings
Fork
1
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaDeserH2HC
/
TestSerialize.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
44 lines (40 loc) · 1.37 KB
Breadcrumbs
JavaDeserH2HC
/
TestSerialize.java
Copy path
File metadata and controls
44 lines (40 loc) · 1.37 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
44
import
java
.
io
.
FileOutputStream
;
import
java
.
io
.
IOException
;
import
java
.
io
.
ObjectOutputStream
;
/**
* Exemplo simples que demonstra a serializacao nativa de um objeto
* e o salva em um arquivo. Observe que, durante a serializacao, o método
* writeObject da classe Alien (que é o tipo do Objeto sendo serializado)
* é automaticamente invocado.
*
* -----------------------------------------------------------------------
* Mais detalhes na 12a edição da H2HC (hackers to hackers) magazine:
* https://www.h2hc.com.br/revista/
* -----------------------------------------------------------------------
*
* **** USAGE ****
*
* Compilando:
* $ javac TestSerialize.java
*
* Executando
* $ java TestSerialize
*
* @author @joaomatosf
*/
public
class
TestSerialize
{
public
static
void
main
(
String
[]
args
)
throws
IOException
{
// Instancia objeto a ser serializado e atribui
// valores aos seus campos "name" e "source"
Alien
ET
=
new
Alien
();
ET
.
name
=
"Abu ce taí"
;
ET
.
source
=
"Andromeda Galaxy"
;
// Cria FileOutputStream para armazenar o objeto serializado em um arquivo
FileOutputStream
fos
=
new
FileOutputStream
(
"ET_object.ser"
);
ObjectOutputStream
oos
=
new
ObjectOutputStream
(
fos
);
oos
.
writeObject
(
ET
);
// <-- Realiza a serializacao
oos
.
flush
();
oos
.
close
();
}
}
Back
|
FazBrowse Home
|
New Git URL