Skip to content
This repository has been archived by the owner on Jun 29, 2021. It is now read-only.

Commit

Permalink
LocalFilestoresDetails
Browse files Browse the repository at this point in the history
  • Loading branch information
kalpaj12 committed Dec 11, 2018
1 parent 7fc61a9 commit bbe40aa
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 34 deletions.
43 changes: 15 additions & 28 deletions ServerFiles/FilesofDirec.java
Original file line number Diff line number Diff line change
@@ -1,45 +1,32 @@
import java.io.File;
import java.io.*;

public class FilesofDirec {

public void listFilesAndFolders(String directoryName) {
File directory = new File(directoryName);
File[] fList = directory.listFiles();
for (File file : fList) {
System.out.println(file.getName());
}
}
public String filePath() {
String operSys = System.getProperty("os.name").toLowerCase();

public void listFiles(String directoryName) {
File directory = new File(directoryName);
File[] fList = directory.listFiles();
for (File file : fList) {
if (file.isFile()) {
System.out.println(file.getName());
}
if (operSys.startsWith("windows")) {
return "\\";
} else {
return "/";
}
}

public void listFolders(String directoryName) {
File directory = new File(directoryName);
File[] fList = directory.listFiles();
for (File file : fList) {
if (file.isDirectory()) {
System.out.println(file.getName());
}
}
}
public void listFilesAndFilesSubDirectories(String directoryName) throws IOException {

String FileDir = directoryName + filePath() + "FilesinServer.txt";
PrintStream WritetoFile = new PrintStream(new File(FileDir));

public void listFilesAndFilesSubDirectories(String directoryName) {
File directory = new File(directoryName);
File[] fList = directory.listFiles();
for (File file : fList) {
if (file.isFile()) {
System.out.println(file.getAbsolutePath());
if (file.isFile() && file.getName().compareToIgnoreCase("FilesinServer.txt") != 0) {
WritetoFile.println(file.getName());
} else if (file.isDirectory()) {
listFilesAndFilesSubDirectories(file.getAbsolutePath());
WritetoFile.println(file.getAbsolutePath());
}
}
WritetoFile.close();
}

}
13 changes: 8 additions & 5 deletions ServerFiles/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,14 @@ public static void listen() throws IOException {

nioServer.readFileFromSocket(socketChannel, fullPath);

System.out.println("\n------------------------------");
System.out.println("Files in Server");
FilesofDirec FilesofDirec = new FilesofDirec();
FilesofDirec.listFiles(storagePath);
System.out.println("------------------------------\n");
// System.out.println("\n------------------------------");
// System.out.println("Files in Server");
try {
FilesofDirec FilesofDirec = new FilesofDirec();
FilesofDirec.listFilesAndFilesSubDirectories(storagePath);
} catch (IOException e) {
}
// System.out.println("------------------------------\n");

serverSocketChannel.close();

Expand Down
4 changes: 3 additions & 1 deletion ServerFiles/ServerGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,9 @@ private void updateStorageField() {
private void updateFileList() {
listModel.clear();
for (File file : directory.listFiles()) {
listModel.addElement(file.getName());
String FileName = file.getName();
if (FileName.compareToIgnoreCase("FilesinServer.txt") != 0)
listModel.addElement(file.getName());
}
fileList.setModel(listModel);
}
Expand Down

0 comments on commit bbe40aa

Please sign in to comment.