0
특정 위치의 파일이 서버 프로젝트의 다른 폴더에 추가됩니다.버튼을 누를 때 서버에서 파일 다운로드
프로젝트 FileShareServer 내가 클라이언트 측에서 버튼을 눌렀을 때 서버에서 클라이언트로 파일을 다운로드하는 것입니다 무엇을 필요로
private boolean writefiletoServerfolder() throws IOException {
String filetype = categorycombo.getValue().toString();
// int i = 0;
File file = null;
File imagefile = null;
String imagename=null;
String filename=null;
FileChannel channel = null;
FileOutputStream fileOutputStream = null;
FileInputStream fileinputstream = null;
//map=new HashMap<>();
for (int i = 0; i < fileList.size(); i++) {
if (filetype.equals("Apps")) {
file = new File("D:\\SERVER\\Server Content\\Apps\\" + fileList.get(i).getName());
imagefile = new File("D:\\SERVER\\Server Content\\Apps\\icons\\" + imagelist.get(i).getName());
imagename=imagefile.getName();
filename=file.getName();
//map.put(filename, imagename);
} else if (filetype.equals("Games")) {
file = new File("D:\\SERVER\\Server Content\\Games\\" + fileList.get(i).getName());
imagefile = new File("D:\\SERVER\\Server Content\\Games\\icons\\" + imagelist.get(i).getName());
imagename=imagefile.getName();
filename=file.getName();
// map.put(filename, imagename);
} else if (filetype.equals("Movies")) {
file = new File("D:\\SERVER\\Server Content\\Movies\\" + fileList.get(i).getName());
imagefile = new File("D:\\SERVER\\Server Content\\Movies\\icons\\" + imagelist.get(i).getName());
imagename=imagefile.getName();
filename=file.getName();
//map.put(filename, imagename);
} else if (filetype.equals("Songs")) {
file = new File("D:\\SERVER\\Server Content\\Songs\\" + fileList.get(i).getName());
imagefile = new File("D:\\SERVER\\Server Content\\Songs\\icons\\" + imagelist.get(i).getName());
imagename=imagefile.getName();
filename=file.getName();
// map.put(filename, imagename);
}
}
List<File> fileandimagedest = new ArrayList();
fileandimagedest.add(file);
fileandimagedest.add(imagefile);
List<String> fileandimagesrc = new ArrayList();
fileandimagesrc.add(filepath);
fileandimagesrc.add(imagepath);
boolean bool = false;
for (String path : fileandimagesrc) {
for (File file1 : fileandimagedest) {
try {
fileinputstream = new FileInputStream(path);
fileOutputStream = new FileOutputStream(file1);
long starttime = System.currentTimeMillis();
byte[] buf = new byte[1024];
int byteRead;
while ((byteRead = fileinputstream.read(buf)) > 0) {
fileOutputStream.write(buf, 0, byteRead);
bool = true;
}
} finally {
if (bool) {
fileinputstream.close();
fileOutputStream.close();
}
}
}
}
return true;
}
.
프로젝트 파일 공유 클라이언트.
public void downloadbuttonAction() {
downloadbtn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
}
});
}
이미 서버에서 파일을 다운로드하도록 구현되었습니다. 버튼을 누르면 간단히 수행해야합니다.
그냥 당신이 작성한 메소드를 호출 – ItachiUchiha