org.rx.io.CrudFile Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rxlib Show documentation
Show all versions of rxlib Show documentation
A set of utilities for Java
package org.rx.io;
import org.apache.commons.io.FilenameUtils;
import org.rx.core.Linq;
import org.rx.core.Strings;
import java.io.InputStream;
public interface CrudFile {
default boolean isDirectoryPath(String path) {
if (Strings.isEmpty(path)) {
return false;
}
char ch = path.charAt(path.length() - 1);
return ch == '/' || ch == '\\' || Strings.isEmpty(FilenameUtils.getExtension(path));
}
default String getDirectoryPath(String path) {
return FilenameUtils.getFullPath(path);
}
default String padDirectoryPath(String path) {
if (Strings.isEmpty(path)) {
return Strings.EMPTY;
}
char ch = path.charAt(path.length() - 1);
if (ch == '/' || ch == '\\') {
return path;
}
char separatorChar = path.lastIndexOf('\\') != -1 ? '\\' : '/';
return path + separatorChar;
}
String createDirectory(String path);
Linq listDirectories(String directoryPath, boolean recursive);
void saveFile(String filePath, InputStream in);
Linq listFiles(String directoryPath, boolean recursive);
boolean exists(String path);
void delete(String path);
}