📄 fileconnection.html
字号:
<PRE>
public java.io.InputStream <B>openInputStream</B>()
throws java.io.IOException</PRE>
<DL>
<DD>
Open and return an input stream for a connection. The connection's target must
already exist and be accessible for the input stream to be created.
<P></P>
<DD>
<DL>
<DT><B>Specified by:</B><DD><CODE>openInputStream</CODE> in interface <CODE>javax.microedition.io.InputConnection</CODE></DD></DL>
<DD>
<DL>
<DT><B>Returns:</B><DD>An open input stream <DT><B>Throws:</B>
<DD>
<CODE>java.io.IOException</CODE> - if an I/O error occurs, if the method is
invoked on a directory, if the connection's target does not yet exist, or the
connection's target is not accessible.
<DD>
<CODE><A HREF="../../../../javax/microedition/io/file/IllegalModeException.html">IllegalModeException</A></CODE>
- if the application does have read access to the connection's target but has
opened the connection in <code>Connector.WRITE</code> mode.
<DD>
<CODE>java.lang.SecurityException</CODE> - If the application is not granted
read access to the connection's target.</DD></DL>
</DD>
</DL>
<HR>
<A NAME="openDataInputStream()"><!-- --></A><H3>
openDataInputStream</H3>
<PRE>
public java.io.DataInputStream <B>openDataInputStream</B>()
throws java.io.IOException</PRE>
<DL>
<DD>
Open and return a data input stream for a connection. The connection's target
must already exist and be accessible for the input stream to be created.
<P></P>
<DD>
<DL>
<DT><B>Specified by:</B><DD><CODE>openDataInputStream</CODE> in interface <CODE>javax.microedition.io.InputConnection</CODE></DD></DL>
<DD>
<DL>
<DT><B>Returns:</B><DD>An open input stream <DT><B>Throws:</B>
<DD>
<CODE>java.io.IOException</CODE> - If an I/O error occurs, if the method is
invoked on a directory, if the connection's target does not yet exist, or the
connection's target is not accessible.
<DD>
<CODE><A HREF="../../../../javax/microedition/io/file/IllegalModeException.html">IllegalModeException</A></CODE>
- if the application does have read access to the connection's target but has
opened the connection in <code>Connector.WRITE</code> mode.
<DD>
<CODE>java.lang.SecurityException</CODE> - If the application is not granted
read access to the connection's target.</DD></DL>
</DD>
</DL>
<HR>
<A NAME="openOutputStream()"><!-- --></A><H3>
openOutputStream</H3>
<PRE>
public java.io.OutputStream <B>openOutputStream</B>()
throws java.io.IOException</PRE>
<DL>
<DD>
Open and return an output stream for a connection. The output stream is
positioned at the start of the file. Writing data to the output stream
overwrites the contents of the files (i.e. does not insert data). Writing data
to output streams beyond the current end of file automatically extends the file
size. The connection's target must already exist and be accessible for the
output stream to be created. <A HREF="../../../../javax/microedition/io/file/FileConnection.html#openOutputStream(long)">
<CODE>openOutputStream(long)</CODE></A> should be used to position an
output stream to a different position in the file.
<P>
Changes made to a file through an output stream may not be immediately made to
the actual file residing on the file system because platform and implementation
specific use of caching and buffering of the data. Stream contents and file
length extensions are not necessarily visible outside of the application
immediately unless <code>flush()</code> is called on the stream. The
returned output stream is automatically and synchronously flushed when it is
closed.
</P>
<P></P>
<DD>
<DL>
<DT><B>Specified by:</B><DD><CODE>openOutputStream</CODE> in interface <CODE>javax.microedition.io.OutputConnection</CODE></DD></DL>
<DD>
<DL>
<DT><B>Returns:</B><DD>An open output stream <DT><B>Throws:</B>
<DD>
<CODE>java.io.IOException</CODE> - If an I/O error occurs, if the method is
invoked on a directory, the file does not yet exist, or the connection's target
is not accessible.
<DD>
<CODE><A HREF="../../../../javax/microedition/io/file/IllegalModeException.html">IllegalModeException</A></CODE>
- if the application does have write access to the connection's target but has
opened the connection in <code>Connector.READ</code> mode.
<DD>
<CODE>java.lang.SecurityException</CODE> - If the application is not granted
write access to the connection's target.<DT><B>See Also:</B><DD><A HREF="../../../../javax/microedition/io/file/FileConnection.html#openOutputStream(long)"><CODE>openOutputStream(long)</CODE></A></DD></DL>
</DD>
</DL>
<HR>
<A NAME="openDataOutputStream()"><!-- --></A><H3>
openDataOutputStream</H3>
<PRE>
public java.io.DataOutputStream <B>openDataOutputStream</B>()
throws java.io.IOException</PRE>
<DL>
<DD>
Open and return a data output stream for a connection. The output stream is
positioned at the start of the file. Writing data to the output stream
overwrites the contents of the files (i.e. does not insert data). Writing data
to output streams beyond the current end of file automatically extends the file
size. The connection's target must already exist and be accessible for the
output stream to be created. <A HREF="../../../../javax/microedition/io/file/FileConnection.html#openOutputStream(long)">
<CODE>openOutputStream(long)</CODE></A> should be used to position an
output stream to a different position in the file.
<P>
Changes made to a file through an output stream may not be immediately made to
the actual file residing on the file system because platform and implementation
specific use of caching and buffering of the data. Stream contents and file
length extensions are not necessarily visible outside of the application
immediately unless <code>flush()</code> is called on the stream. The
returned output stream is automatically and synchronously flushed when it is
closed.
</P>
<P></P>
<DD>
<DL>
<DT><B>Specified by:</B><DD><CODE>openDataOutputStream</CODE> in interface <CODE>javax.microedition.io.OutputConnection</CODE></DD></DL>
<DD>
<DL>
<DT><B>Returns:</B><DD>An open output stream <DT><B>Throws:</B>
<DD>
<CODE>java.io.IOException</CODE> - If an I/O error occurs, if the method is
invoked on a directory, the file does not yet exist, or the connection's target
is not accessible.
<DD>
<CODE><A HREF="../../../../javax/microedition/io/file/IllegalModeException.html">IllegalModeException</A></CODE>
- if the application does have write access to the connection's target but has
opened the connection in <code>Connector.READ</code> mode.
<DD>
<CODE>java.lang.SecurityException</CODE> - If the application is not granted
write access to the connection's target.<DT><B>See Also:</B><DD><A HREF="../../../../javax/microedition/io/file/FileConnection.html#openOutputStream(long)"><CODE>openOutputStream(long)</CODE></A></DD></DL>
</DD>
</DL>
<HR>
<A NAME="openOutputStream(long)"><!-- --></A><H3>
openOutputStream</H3>
<PRE>
public java.io.OutputStream <B>openOutputStream</B>(long byteOffset)
throws java.io.IOException</PRE>
<DL>
<DD>
This method opens an output stream and positions it at the indicated byte
offset in the file. Data written to the returned output stream at that position
overwrites any existing data until EOF is reached, and then additional data is
appended. The connection's target must already exist and be accessible for the
output stream to be created.
<P>
Changes made to a file through an output stream may not be immediately made to
the actual file residing on the file system because platform and implementation
specific use of caching and buffering of the data. Stream contents and file
length extensions are not necessarily visible outside of the application
immediately unless <code>flush()</code> is called on the stream. The
returned output stream is automatically and synchronously flushed when it is
closed.
</P>
<P></P>
<DD>
<DL>
</DL>
<DD>
<DL>
<DT><B>Parameters:</B><DD><CODE>byteOffset</CODE> - number of bytes to skip over from
the beginning of the file when positioning the start of the OutputStream. If
the provided offset is larger than or equal to the current file size, the
OutputStream is positioned at the current end of the file for appending. <DT><B>Returns:</B><DD>an
open OutputStream positioned at the byte offset in the file, or the end of the
file if the offset is greater than the size of the file. <DT><B>Throws:</B>
<DD>
<CODE>java.io.IOException</CODE> - If an I/O error occurs, if the method is
invoked on a directory, the file does not yet exist, or the connection's target
is not accessible.
<DD>
<CODE><A HREF="../../../../javax/microedition/io/file/IllegalModeException.html">IllegalModeException</A></CODE>
- if the application does have write access to the connection's target but has
opened the connection in <code>Connector.READ</code> mode.
<DD>
<CODE>java.lang.SecurityException</CODE> - if the security if the application
does not allow write access to the file.
<DD>
<CODE>java.lang.IllegalArgumentException</CODE> - if byteOffset has a negative
value.</DD></DL>
</DD>
</DL>
<HR>
<A NAME="totalSize()"><!-- --></A><H3>
totalSize</H3>
<PRE>
public long <B>totalSize</B>()</PRE>
<DL>
<DD>
Determines the total size of the file system the connection's target resides
on.
<P></P>
<DD>
<DL>
</DL>
<DD>
<DL>
<DT><B>Returns:</B><DD>The total size of the file system in bytes, or -1 if the file
system is not accessible. <DT><B>Throws:</B>
<DD>
<CODE>java.lang.SecurityException</CODE> - if the security of the application
does not have read access to the root volume.
<DD>
<CODE><A HREF="../../../../javax/microedition/io/file/IllegalModeException.html">IllegalModeException</A></CODE>
- if the application does have read access to the connection's target but has
opened the connection in <code>Connector.WRITE</code> mode.
<DD>
<CODE><A HREF="../../../../javax/microedition/io/file/ConnectionClosedException.html">ConnectionClosedException</A></CODE>
- if the connection is closed.</DD></DL>
</DD>
</DL>
<HR>
<A NAME="availableSize()"><!-- --></A><H3>
availableSize</H3>
<PRE>
public long <B>availableSize</B>()</PRE>
<DL>
<DD>
Determines the free memory that is available on the file system the file or
directory resides on. This may only be an estimate and may vary based on
platform-specific file system blocking and metadata information.
<P></P>
<DD>
<DL>
</DL>
<DD>
<DL>
<DT><B>Returns:</B><DD>The available size in bytes on a file system, or -1 if the file
system is not accessible. <DT><B>Throws:</B>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -