Interface AIInOut
-
- All Known Implementing Classes:
AIInOut.AIFileInOut,AIInOut.AIFileSegmentInOut,AIInOut.AIStreamInOut
public interface AIInOutAIInOut is an interface that represents an input or output for AI tasks. We join input and output since in some cases we need to read the file, too.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classAIInOut.AIFileInOutAIFileInOut is an implementation of AIInOut that reads from a file.static classAIInOut.AIFileSegmentInOutAIFileSegmentInOut is an implementation of AIInOut that reads from a segment of a segmented file.static classAIInOut.AIStreamInOutAIStreamInOut is an implementation of AIInOut that reads from an input stream.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default booleanexists()FilegetFile()The underlying file.static AIInOutof(File file)Creates an AIInOut instance that reads from a file.static AIInOutof(InputStream in)Creates an AIInOut instance that reads from an input stream.static AIInOutof(Path path)Creates an AIInOut instance that reads from a file.static AIInOutof(SegmentedFile segmentedFile, int segmentIndex)Creates an AIInOut instance that reads from a segment of a segmented file.Stringread()Reads the input and returns it as a string.default booleansameFile(AIInOut other)voidwrite(String content)Writes a string to the output.
-
-
-
Method Detail
-
read
String read() throws IllegalStateException
Reads the input and returns it as a string.- Returns:
- the input as a string
- Throws:
IllegalStateException- if the input cannot be read
-
write
void write(String content)
Writes a string to the output.- Parameters:
content- the string to write
-
getFile
File getFile()
The underlying file.
-
sameFile
default boolean sameFile(AIInOut other)
-
exists
default boolean exists()
-
of
@Nullable static AIInOut of(@Nullable File file)
Creates an AIInOut instance that reads from a file.- Parameters:
file- the file to read from- Returns:
- an AIInOut instance
-
of
@Nullable static AIInOut of(@Nullable Path path)
Creates an AIInOut instance that reads from a file.- Parameters:
path- the path to the file to read from- Returns:
- an AIInOut instance
-
of
@Nonnull static AIInOut of(@Nonnull SegmentedFile segmentedFile, int segmentIndex)
Creates an AIInOut instance that reads from a segment of a segmented file.- Parameters:
segmentedFile- the segmented file to read fromsegmentIndex- the index of the segment to read- Returns:
- an AIInOut instance
-
of
static AIInOut of(InputStream in)
Creates an AIInOut instance that reads from an input stream. Writing is not supported.- Parameters:
in- the input stream to read from- Returns:
- an AIInOut instance
-
-