
eu.cedarsoft.devtools.FileTools Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core Show documentation
Show all versions of core Show documentation
Core classes for DevTools
The newest version!
package eu.cedarsoft.devtools;
import eu.cedarsoft.utils.CmdLine;
import eu.cedarsoft.utils.Renderer;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.Arrays;
/**
*
*/
public class FileTools {
private FileTools() {
}
@NotNull
public static File readFile( @NotNull CmdLine cmdLine, @NotNull String description ) throws IOException {
return readFile( cmdLine, description, new File( "." ).listFiles() );
}
@NotNull
public static File readFile( @NotNull CmdLine cmdLine, @NotNull String description, @NotNull @NonNls final String suffix ) throws IOException {
return readFile( cmdLine, description, new File( "." ).listFiles( new FilenameFilter() {
public boolean accept( File dir, String name ) {
return name.endsWith( suffix );
}
} ) );
}
@NotNull
public static File readFile( @NotNull CmdLine cmdLine, @NotNull String description, @Nullable File[] proposals ) throws IOException {
return cmdLine.readSelection( description, Arrays.asList( proposals ), new Renderer() {
@NotNull
public String render( @NotNull File object, @Nullable Object context ) {
return object.getName();
}
} );
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy