Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Projet GORDYJAN_BAGNOLY_GARCIA_POIGNONNEC
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
POIGNONNEC
Projet GORDYJAN_BAGNOLY_GARCIA_POIGNONNEC
Commits
947e65b6
Commit
947e65b6
authored
May 15, 2019
by
Gaetan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[MAIN] Lecture / écriture dans un fichier de l'objet garage
parent
182093b9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
0 deletions
+49
-0
Main.java
garage/src/main/Main.java
+49
-0
No files found.
garage/src/main/Main.java
View file @
947e65b6
package
main
;
import
garage.*
;
import
java.io.*
;
import
java.util.*
;
import
vehicle.*
;
public
class
Main
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
// Déclaration des objets :
ObjectInputStream
ois
;
ObjectOutputStream
oos
;
Garage
stockGarage
=
new
Garage
();
// Affichage titre :
System
.
out
.
println
(
" *********************** \n * "
+
stockGarage
.
getGarageName
()
+
" * \n ***********************\n"
);
// Lecture du fichier ou les véhicules sont sauvegardés :
try
{
ois
=
new
ObjectInputStream
(
new
BufferedInputStream
(
new
FileInputStream
(
new
File
(
"garage.txt"
))));
stockGarage
=
new
Garage
((
LinkedList
<
Vehicle
>)
ois
.
readObject
());
ois
.
close
();
}
catch
(
FileNotFoundException
e
)
{
System
.
out
.
println
(
"Aucune voitures sauvegarder !\n"
);
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"Aucune voitures sauvegarder !\n"
);
}
catch
(
ClassNotFoundException
e
)
{
e
.
printStackTrace
();
}
// CREATE vehicle LAGUNA
// CREATE vehicle D4
// CREATE vehicle A300B
// Ecriture de la liste de véhicule dans le fichier :
try
{
oos
=
new
ObjectOutputStream
(
new
BufferedOutputStream
(
new
FileOutputStream
(
new
File
(
"garage.txt"
))));
oos
.
writeObject
(
stockGarage
.
getStock
());
oos
.
close
();
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment