@@ -51,10 +51,6 @@ public RecentFiles(Class<?> className, int maximumFile)
5151 this .maximum = maximumFile ;
5252 this .pref = Preferences .userNodeForPackage (className );
5353 filePaths = readHistoryFromPref ();
54- if (filePaths == null )
55- {
56- filePaths = new ArrayDeque <>();
57- }
5854 }
5955
6056 /**
@@ -108,18 +104,14 @@ public void removeFile(String path)
108104 */
109105 public List <String > getFiles ()
110106 {
111- if (!isEmpty ())
107+ List <String > files = filePaths .stream ().
108+ filter (path -> new File (path ).exists ()).
109+ collect (Collectors .toList ());
110+ if (files .size () > maximum )
112111 {
113- List <String > files = filePaths .stream ().
114- filter (path -> new File (path ).exists ()).
115- collect (Collectors .toList ());
116- if (files .size () > maximum )
117- {
118- files .remove (0 );
119- }
120- return files ;
112+ files .remove (0 );
121113 }
122- return null ;
114+ return files ;
123115 }
124116
125117 /**
@@ -175,12 +167,7 @@ private Queue<String> readHistoryFromPref()
175167 {
176168 Preferences node = pref .node (KEY );
177169 int historyLength = node .getInt (HISTORY_LENGTH , 0 );
178- if (historyLength == 0 )
179- {
180- return null ;
181- }
182170 Queue <String > history = new ArrayDeque <>();
183-
184171 for (int i = 1 ; i <= historyLength ; i ++)
185172 {
186173 int totalPieces = node .getInt (String .format (PIECES_LENGTH_KEY , i ), 0 );
0 commit comments