br.com.objectos.fs
Interface WritablePathName

All Superinterfaces:
OutputStreamSource, PathName, WriterSource
All Known Subinterfaces:
RegularFile, ResolvedPath

public interface WritablePathName
extends PathName, OutputStreamSource, WriterSource

A façade for writing operations. Instances of this interface may represent an existing file or the pathname of a file that will be created.

This interface can be used as the destination in methods from the Copy and Write classes.

Since:
2
See Also:
Copy, Write

Method Summary
<R,P> R
acceptPathNameVisitor(PathNameVisitor<R,P> visitor, P p)
          Accept method used to implement the visitor pattern.
 boolean exists()
          Returns true if the pathname represented by this object exists.
 String getName()
          Returns the name of this object.
 String getPath()
          Returns the full path of this object.
 OutputStream openOutputStream()
          Returns a new output stream for writing to this pathname.
 FileChannel openWriteChannel()
          Returns a new channel for writing to this pathname.
 Writer openWriter(Charset charset)
          Returns a new writer for writing characters to this pathname.
 File toFile()
          Returns a File representation of this pathname.
 URI toUri()
          Returns an URI representation of this pathname.
 
Methods inherited from interface java.lang.Comparable
compareTo
 
Methods inherited from interface br.com.objectos.core.object.ToStringObject
formatToString
 

Method Detail

openOutputStream

OutputStream openOutputStream()
                              throws IOException
Returns a new output stream for writing to this pathname.

The file is created if it does not exist. If the file exists then the returned output stream will be in append mode.

Specified by:
openOutputStream in interface OutputStreamSource
Returns:
a new output stream for writing to this file
Throws:
IOException - if an I/O error occurs

openWriteChannel

FileChannel openWriteChannel()
                             throws IOException
Returns a new channel for writing to this pathname.

The returned channel is open in write-only mode. The file is created if it does not exist. If the file exists then the returned channel's initial position is the file size.

Returns:
a new channel for writing to this file. The returned channel is open in write-only mode and its initial position is the file size
Throws:
IOException - if an I/O error occurs

openWriter

Writer openWriter(Charset charset)
                  throws IOException
Returns a new writer for writing characters to this pathname.

The file is created if it does not exist. If the file exists then the returned writer will be in append mode.

Specified by:
openWriter in interface WriterSource
Parameters:
charset - the charset to use for encoding
Returns:
a new writer for writing characters to this pathname
Throws:
IOException - if an I/O error occurs

acceptPathNameVisitor

<R,P> R acceptPathNameVisitor(PathNameVisitor<R,P> visitor,
                              P p)
                        throws IOException
Accept method used to implement the visitor pattern.

Type Parameters:
R - the result type of this operation
P - the type of the additional object
Parameters:
visitor - the visitor operating on this PathName instance
p - additional object passed to the visitor
Returns:
the value returned from the visitor method
Throws:
IOException - if an I/O error occurs

exists

boolean exists()
Returns true if the pathname represented by this object exists.

Returns:
true if the pathname represented by this object exists

getName

String getName()
Returns the name of this object.

Returns:
the name of this object

getPath

String getPath()
Returns the full path of this object.

Returns:
the full path of this object

toFile

File toFile()
Returns a File representation of this pathname.

Returns:
a File representation of this pathname

toUri

URI toUri()
Returns an URI representation of this pathname.

Returns:
an URI representation of this pathname


Copyright © 2021 Objectos Software LTDA. All rights reserved.