Browse Source

changes

master
michael 2 years ago
parent
commit
9fb822418b
2 changed files with 7 additions and 5 deletions
  1. BIN
      bin/listarFichero/listarFichero.class
  2. +7
    -5
      src/listarFichero/listarFichero.java

BIN
bin/listarFichero/listarFichero.class View File


+ 7
- 5
src/listarFichero/listarFichero.java View File

@ -40,7 +40,7 @@ import java.util.Objects;
int indent = 5;
System.out.printf("%10s %5s %6s %7s \n\n ", "NAME" ,"OWNERSHIP","SIZE", "DATE");
for (int i = 0; i < Objects.requireNonNull(files).length; i++) {
System.out.printf("%10s %2s %5s %6s %2s %7s %n", files[i] , "", printOwnership(file), printSize(file),"", printDate(file));
System.out.printf("%10s %2s %5s %6s %2s %7s %n", files[i] , "", printOwnership(files[i]), printSize(files[i]),"", printDate(files[i]));
}
}
@ -49,8 +49,9 @@ import java.util.Objects;
//Sacar el tamnyo del fichero
public static String printSize(File file) {
public static String printSize(String fileStr) {
File file = new File(fileStr);
String resultado = "";
long bytes = file.length();
@ -84,7 +85,8 @@ import java.util.Objects;
public static String printDate(File file){
public static String printDate(String fileStr){
File file = new File(fileStr);
long ms = file.lastModified();
Date d = new Date(ms);
Calendar c = new GregorianCalendar();
@ -104,8 +106,8 @@ import java.util.Objects;
}
public static String printOwnership(File file) {
public static String printOwnership(String fileStr) {
File file = new File(fileStr);
String read = "", write = "", execute = "";
if(file.canRead() == true) {


Loading…
Cancel
Save