Package evo.search.io.service
Class FileService
- java.lang.Object
-
- evo.search.io.service.FileService
-
public class FileService extends Object
File prompting and loading service.
-
-
Constructor Summary
Constructors Constructor Description FileService()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intcounter(Path path, String prefix, String suffix)Counts the files matching the pattern prefix-number.suffixstatic PathpromptForDirectory()Shorthand forpromptForDirectory(String)with "Load directory" in the title.static PathpromptForDirectory(String title)Prompt the user for a directory.static PathpromptForLoad(String title)Prompt the user for a file path.static PathpromptForSave(String title, String extension)Prompt the user for a file save path.static org.dom4j.Documentread(Path file)Read a xmlDocumentfrom a file.static PathuniquePath(String name, String ext)Get a distinct file from the file system.static voidwrite(Path path, org.dom4j.Document document)Write a xmlDocumentto a file.static voidwrite(Path path, org.dom4j.Element element)Write a xmlElementas root element to a file.
-
-
-
Method Detail
-
promptForLoad
public static Path promptForLoad(String title)
Prompt the user for a file path.- Parameters:
title- the prompts title- Returns:
- the chosen file's path from the prompt
-
promptForSave
public static Path promptForSave(String title, String extension)
Prompt the user for a file save path.- Parameters:
title- the prompts title- Returns:
- the chosen file's path from the prompt
-
promptForDirectory
public static Path promptForDirectory(String title)
Prompt the user for a directory.- Parameters:
title- the prompts title- Returns:
- the chosen directory's path from the prompt
- See Also:
promptForLoad(String)
-
promptForDirectory
public static Path promptForDirectory()
Shorthand forpromptForDirectory(String)with "Load directory" in the title.- Returns:
- the chosen directory's path from the prompt
- See Also:
promptForDirectory(String),promptForLoad(String)
-
write
public static void write(Path path, org.dom4j.Document document)
Write a xmlDocumentto a file.- Parameters:
path- files pathdocument- xml document to write
-
write
public static void write(Path path, org.dom4j.Element element)
Write a xmlElementas root element to a file.- Parameters:
path- file pathelement- xml element to write
-
read
public static org.dom4j.Document read(Path file)
Read a xmlDocumentfrom a file.- Parameters:
file- the files path- Returns:
- parsed xml document
-
uniquePath
public static Path uniquePath(String name, String ext)
Get a distinct file from the file system.- Parameters:
name- name prefix to useext- file extension to use- Returns:
- file handler to a distinct file
-
-