Class FileUtil
java.lang.Object
com.vividsolutions.jump.util.FileUtil
File-related utility functions.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic FileaddExtensionIfNone(File file, String extension) static voidstatic FilecopyInputStreamToTempFile(InputStream in, String prefix, String suffix, TaskMonitor monitor) utility method to copy an inputstream to a temp file for further processing NOTE: prefix, suffix, monitor are optional and may be}invalid @link
{@link <code>null</code>static FilefindFileInClassPath(String fileOrFolder) utility method to find files or folders in classpath easy without handling exceptions or such returns NULL if none could b foundgetContents(InputStream inputStream) Gets the content of an inputSteam as a list of lines.getContents(InputStream inputStream, String encoding) Gets the content of an inputSteam as a list of lines. inputStream is decoded with the specified charset.getContents(String filename) Gets the content of filename as a list of lines.getContents(String filename, String encoding) Gets the content of filename as a list of lines.getContents(URI uri) Gets the content a compressed file passed as an URI.static StringgetExtension(File f) static Stringstatic StringgetFileNameFromLayerName(String layerName) static FileremoveExtensionIfAny(File file) static voidsetContents(String filename, String contents) Saves the String to a file with the given filename.static voidsetContents(String filename, String contents, String encoding) Saves lines into a file named filename, using encoding charset.static voidsetContents(String filename, List<String> lines) Saves the List of Strings to a file with the given filename.static voidsetContents(String filename, List<String> lines, String encoding) Saves lines into a file named filename, using encoding charset.static voidzip(Collection<File> files, File zipFile)
-
Field Details
-
I18NPREFIX
-
PREFIX
- See Also:
-
SUFFIX
- See Also:
-
-
Constructor Details
-
FileUtil
public FileUtil()
-
-
Method Details
-
getContents
Gets the content of filename as a list of lines.- Parameters:
filename- name of the input file- Returns:
- a list of strings representing the file's lines
- Throws:
IOException- if an IOException occurred
-
getContents
Gets the content of filename as a list of lines.- Parameters:
filename- name of the input fileencoding- charset to use to decode filename- Returns:
- a list of strings representing the file's lines
- Throws:
IOException- if an Exception occurred
-
getContents
Gets the content a compressed file passed as an URI.- Parameters:
uri- uri of the input resource- Returns:
- a list of strings representing the compressed file's lines
- Throws:
IOException- if an Exception occurred
-
getContents
Gets the content of an inputSteam as a list of lines.- Parameters:
inputStream- inputStream to read from- Returns:
- a list of lines
- Throws:
IOException- if an Exception occurred
-
getContents
Gets the content of an inputSteam as a list of lines. inputStream is decoded with the specified charset.- Parameters:
inputStream- inputStream to read fromencoding- encoding of the inputStream- Returns:
- a list of lines
- Throws:
IOException- if an Exception occurred
-
setContents
Saves the String to a file with the given filename.- Parameters:
filename- the pathname of the file to create (or overwrite)contents- the data to save- Throws:
IOException- if an I/O error occurs.
-
setContents
Saves the List of Strings to a file with the given filename.- Parameters:
filename- the pathname of the file to create (or overwrite)lines- the Strings to save as lines in the file- Throws:
IOException- if an I/O error occurs.
-
setContents
public static void setContents(String filename, String contents, String encoding) throws IOException Saves lines into a file named filename, using encoding charset.- Parameters:
filename- the pathname of the file to create (or overwrite)contents- the data to save- Throws:
IOException- if an I/O error occurs.
-
setContents
public static void setContents(String filename, List<String> lines, String encoding) throws IOException Saves lines into a file named filename, using encoding charset.- Parameters:
filename- the pathname of the file to create (or overwrite)lines- the data to save- Throws:
IOException- if an I/O error occurs.
-
zip
- Throws:
IOException
-
getExtension
-
getExtension
-
addExtensionIfNone
-
removeExtensionIfAny
-
getFileNameFromLayerName
-
close
-
copyInputStreamToTempFile
public static File copyInputStreamToTempFile(InputStream in, String prefix, String suffix, TaskMonitor monitor) throws IOException utility method to copy an inputstream to a temp file for further processing NOTE: prefix, suffix, monitor are optional and may be}invalid @link
{@link <code>null</code>- Parameters:
in- inputSteam to copyprefix- file name prefix - default "openjump"suffix- file name suffix - default ".tmp"monitor- to get feedback during the stream reading- Returns:
- the temp file
- Throws:
IOException- if an Exception occurred
-
findFileInClassPath
-