Skip to content
Snippets Groups Projects
Commit 5c31f22e authored by Sendid Omar's avatar Sendid Omar
Browse files

Dev Architecture Ftp CLient + Test Ftp serveur YOunes Elhassani

parent 6c37f4d5
Branches
No related tags found
No related merge requests found
/**
* TP2 CAR : FTP CLIENT
* By : SENDID Omar
*/
package ftp;
import java.io.File;
import java.util.ArrayList;
public class CLientFile {
private ArrayList<File> filesToUpoad;
private File[] fileList;
private boolean Errors = false;
private String ErrorMessage = new String();
public CLientFile(String[] fileNames){
int numFiles = fileNames.length;
fileList = new File[fileNames.length];
initFiles(fileNames);
filesToUpoad = new ArrayList<File>();
fileSetUpload();
}
private void initFiles(String[] fileNames){
for (int i = 0; i < fileNames.length; i++) {
fileList[i] = new File(fileNames[i]);
}
}
private boolean isFile(File fileName){
return fileName.canRead() && fileName.isFile();
}
private void fileSetUpload(){
String filesToUpload = "Files to be uploaded: ";
for (int i = 0; i < fileList.length; i++){
if(!isFile(fileList[i])){
System.out.println(
fileList[i].getName()
+ " is not file.");
}else{
filesToUpoad.add(fileList[i]);
filesToUpload += fileList[i].getName() + ";";
}
}
System.out.println(filesToUpload);
}
public ArrayList<File> getFilesToUpload(){
return filesToUpoad;
}
public int getNumOfElements(){
return filesToUpoad.size();
}
public boolean getErrors(){
return Errors;
}
public void printErrors(){
System.out.println(ErrorMessage);
System.exit(0);
}
}
package ftp;
/**
* TP2 CAR : FTP CLIENT
* By : SENDID Omar
*/
import java.util.StringTokenizer;
public class ClientArgmuents {
private String Username, Password, Server;
private String[] Files;
private String ErrorMessage = new String();
private boolean Errors = false;
public boolean getErrors(){
return Errors;
}
public void printErrors(){
System.out.println(ErrorMessage);
System.exit(0);
}
public String getUsername() {
return Username;
}
public String getPassword() {
return Password;
}
public String getServer() {
return Server;
}
public String[] getFile() {
return Files;
}
}
\ No newline at end of file
/**
* TP2 CAR : FTP CLIENT
* By : SENDID Omar
*/
package ftp;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class ClientMain {
public static void main(String[] args) throws IOException {
ClientArgmuents arguments = new ClientArgmuents();
String username = arguments.getUsername();
String password = arguments.getPassword();
String server = arguments.getServer();
String [] fileNames = arguments.getFile();
CLientFile files = new CLientFile(fileNames);
int numOfFiles = files.getNumOfElements();
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment