This repository has been archived by the owner on Jun 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
26 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters