TrackFile { @NonNull public String getSize() { if (!file.exists()) { Log.e(TAG, "Missing file in TrackFile.getSize()"); } else if (file.length() == 0) { Log.e(TAG, "Zero length file in TrackFile.getSize()"); } final long size = file.length() >> 10; return size + " kb"; } TrackFile(File file); @NonNull String getName(); @NonNull String getSize(); void archive(@NonNull File destination); @NonNull @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode(); final File file; }
@Test public void trackFileSize() { TrackFile trackFile = new TrackFile(new File("track_2018-01-01_16-20-00.csv.gz")); assertEquals("0 kb", trackFile.getSize()); }