Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
treeftp-tp1-meghari
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Samy Meghari
treeftp-tp1-meghari
Commits
27c3636b
Commit
27c3636b
authored
4 years ago
by
Samy Meghari
Browse files
Options
Downloads
Patches
Plain Diff
modif readme
parent
d969a44f
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Readme.md
+131
-8
131 additions, 8 deletions
Readme.md
with
131 additions
and
8 deletions
Readme.md
+
131
−
8
View file @
27c3636b
## PROJET TREE FTP - MEGHARI Samy
## RESUMÉ
Le but de ce TP est la mise en oeuvre d'un parcours en profondeur qui permet d'afficher en sorti l'arborescence d'un répertoire distant accessible via un protocole FTP
## JAVADOC
>> mvn javadoc:javadoc
...
...
@@ -8,15 +11,135 @@
## EXEMPLE D'EXECUTION
>> java -jar target\TREE.jar [IP SERVEURR]
>> java -jar target\TREE.jar [IP SERVEURR] [PROFONDEUR]
>> java -jar target\TREE.jar [IP SERVEURR] [IDENTIFANT ] [MOT DE PASSE]
>> java -jar target\TREE.jar [IP SERVEURR] [IDENTIFANT ] [MOT DE PASSE] [PROFONDEUR]
java -jar target
\T
REE.jar [IP SERVEURR]
java -jar target
\T
REE.jar [IP SERVEURR] [PROFONDEUR]
java -jar target
\T
REE.jar [IP SERVEURR] [IDENTIFANT ] [MOT DE PASSE]
java -jar target
\T
REE.jar [IP SERVEURR] [IDENTIFANT ] [MOT DE PASSE] [PROFONDEUR]
## ARCHITECTURE
>> **ClientFTP** s'occupe de la connection du client
>> **Tree** s'occupe du parcours en profondeur
>> **ErrorException** est levé dans la plus part des erreurs que j'ai pu identifier
>> **Main** lance l'execution
**ClientFTP**
s'occupe de la connection du client
**Tree**
s'occupe du parcours en profondeur
**ErrorException**
est levé dans la plus part des erreurs que j'ai pu identifier
**Main**
lance l'execution
## EXTRAITS DE CODE
Methode qui permet au client de se connecter
```
java
public
void
init
(
String
ip
,
int
port
)
throws
IOException
,
ErrorException
{
mysocket
=
new
Socket
(
ip
,
port
);
OutputStream
out
=
mysocket
.
getOutputStream
();
PrintWriter
printer
=
new
PrintWriter
(
out
,
true
);
InputStream
in
=
mysocket
.
getInputStream
();
InputStreamReader
isr
=
new
InputStreamReader
(
in
);
BufferedReader
reader
=
new
BufferedReader
(
isr
);
String
content
=
reader
.
readLine
();
System
.
out
.
println
(
content
);
printer
.
println
(
"USER "
+
getUser
().
trim
()
+
"\r\n"
);
content
=
reader
.
readLine
();
System
.
out
.
println
(
content
);
printer
.
println
(
"PASS "
+
getPassword
().
trim
()
+
"\r\n"
);
content
=
reader
.
readLine
();
System
.
out
.
println
(
content
);
}
```
Classe gestion d'erreurs
```
java
public
class
ErrorException
extends
Exception
{
private
static
final
long
serialVersionUID
=
1L
;
public
ErrorException
()
{
super
(
"failed to connect"
);
}
public
ErrorException
(
String
msg
)
{
super
(
msg
);
}
}
```
Methode pour le parcours en profondeur
```
java
public
void
displayFolders
(
String
dir
,
int
profondeur
)
throws
IOException
,
ErrorException
{
List
<
String
>
myFolder
=
new
ArrayList
<>();
myFolder
=
displaymyFolder
(
dir
);
if
(
dir
==
""
)
{
System
.
out
.
println
(
"/"
);
}
else
{
System
.
out
.
println
(
dir
);
}
if
(
myFolder
.
isEmpty
())
{
System
.
out
.
println
(
"empty"
);
return
;
}
for
(
String
s
:
myFolder
)
{
switch
(
s
.
charAt
(
0
))
{
case
(
'd'
):
System
.
out
.
println
(
" └── "
+
s
);
walker
(
dir
+
"/"
+
analyse
(
s
),
""
,
profondeur
-
1
);
break
;
case
(
'l'
):
System
.
out
.
println
(
" └──"
+
s
);
break
;
case
(
'-'
):
System
.
out
.
println
(
" └── "
+
s
);
break
;
default
:
break
;
}
}
}
```
Methode de gestion des inputs utilisateurs
```
java
public
static
void
main
(
String
[]
args
)
throws
IOException
,
ErrorException
{
int
len
=
args
.
length
;
ClientFTP
client
;
String
serveur
=
""
;
Tree
tree
;
if
(
len
>=
1
&&
len
<=
4
)
{
serveur
=
args
[
0
];
client
=
new
ClientFTP
(
"anonymous"
,
"anonymous"
);
client
.
init
(
serveur
,
21
);
tree
=
new
Tree
(
client
);
if
(
len
==
1
)
{
tree
.
displayFolders
(
""
,
3
);
}
else
if
(
len
==
2
)
{
tree
.
displayFolders
(
""
,
Integer
.
parseInt
(
args
[
1
]));
}
else
if
(
len
==
3
)
{
tree
.
displayFolders
(
""
,
3
);
}
else
if
(
len
==
4
)
{
tree
.
displayFolders
(
""
,
Integer
.
parseInt
(
args
[
3
]));
}
}
else
{
System
.
out
.
println
(
"please check the readme"
);
}
}
```
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment