Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.umutayb</groupId>
<artifactId>Utilities</artifactId>
<version>1.7.5</version>
<version>1.7.6</version>
<packaging>jar</packaging>

<name>Java-Utilities</name>
Expand Down
24 changes: 20 additions & 4 deletions src/main/java/utils/FileUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@

import java.io.*;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.nio.file.*;
import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
Expand All @@ -38,6 +35,25 @@ public class FileUtilities {

static Printer log = new Printer(FileUtilities.class);

/**
* Checks if a given string is a valid file path.
*
* @param path The string representing the file path to validate.
* @return true if the string is a valid file path, false otherwise.
*/
public static boolean isValidFilePath(String path) {
if (path == null || path.isEmpty()) return false;

try {
Path filePath = Paths.get(path);
filePath.toRealPath();
return true;
}
catch (InvalidPathException | SecurityException | IOException e) {
return false;
}
}

/**
* Retrieves the Base64-encoded string representation of an image file.
*
Expand Down