| 188 | } |
| 189 | |
| 190 | @NonNull |
| 191 | public static String getShortFileName(@NonNull String fileName) { |
| 192 | Objects.requireNonNull(fileName, "fileName == null"); |
| 193 | if (fileName.isEmpty()) { |
| 194 | throw new IllegalArgumentException("fileName is empty"); |
| 195 | } |
| 196 | if (fileName.endsWith(File.separator)) { |
| 197 | throw new IllegalArgumentException("fileName ends with File.separatorChar"); |
| 198 | } |
| 199 | int index = fileName.lastIndexOf(File.separatorChar); |
| 200 | if (index == -1) { |
| 201 | return fileName; |
| 202 | } else { |
| 203 | return fileName.substring(index + 1); |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | @NonNull |
| 208 | public static String getShortFileName(@NonNull File file) { |