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 int
counter(Path path, String prefix, String suffix)
Counts the files matching the pattern prefix-number.suffixstatic Path
promptForDirectory()
Shorthand forpromptForDirectory(String)
with "Load directory" in the title.static Path
promptForDirectory(String title)
Prompt the user for a directory.static Path
promptForLoad(String title)
Prompt the user for a file path.static Path
promptForSave(String title, String extension)
Prompt the user for a file save path.static org.dom4j.Document
read(Path file)
Read a xmlDocument
from a file.static Path
uniquePath(String name, String ext)
Get a distinct file from the file system.static void
write(Path path, org.dom4j.Document document)
Write a xmlDocument
to a file.static void
write(Path path, org.dom4j.Element element)
Write a xmlElement
as 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 xmlDocument
to a file.- Parameters:
path
- files pathdocument
- xml document to write
-
write
public static void write(Path path, org.dom4j.Element element)
Write a xmlElement
as root element to a file.- Parameters:
path
- file pathelement
- xml element to write
-
read
public static org.dom4j.Document read(Path file)
Read a xmlDocument
from 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
-
-