|
@ -40,7 +40,7 @@ import java.util.Objects; |
|
|
int indent = 5; |
|
|
int indent = 5; |
|
|
System.out.printf("%10s %5s %6s %7s \n\n ", "NAME" ,"OWNERSHIP","SIZE", "DATE"); |
|
|
System.out.printf("%10s %5s %6s %7s \n\n ", "NAME" ,"OWNERSHIP","SIZE", "DATE"); |
|
|
for (int i = 0; i < Objects.requireNonNull(files).length; i++) { |
|
|
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 |
|
|
//Sacar el tamnyo del fichero |
|
|
|
|
|
|
|
|
public static String printSize(File file) { |
|
|
|
|
|
|
|
|
public static String printSize(String fileStr) { |
|
|
|
|
|
|
|
|
|
|
|
File file = new File(fileStr); |
|
|
String resultado = ""; |
|
|
String resultado = ""; |
|
|
|
|
|
|
|
|
long bytes = file.length(); |
|
|
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(); |
|
|
long ms = file.lastModified(); |
|
|
Date d = new Date(ms); |
|
|
Date d = new Date(ms); |
|
|
Calendar c = new GregorianCalendar(); |
|
|
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 = ""; |
|
|
String read = "", write = "", execute = ""; |
|
|
|
|
|
|
|
|
if(file.canRead() == true) { |
|
|
if(file.canRead() == true) { |
|
|