⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 owfileoutputstream.java

📁 这是一个以JAVA编写的程序,本人还没有试过,是一个简单的温度控制系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    *               <code>checkWrite</code> method denies write access    *               to the file.    */   public OWFileOutputStream(OneWireContainer owd, String name,                             boolean append)      throws OWFileNotFoundException   {      fd = new OWFileDescriptor(owd, name);      try      {         fd.create(append, false, false, -1, -1);      }      catch (OWFileNotFoundException e)      {         fd.free();         fd = null;         throw new OWFileNotFoundException(e.toString());      }   }   /**    * Creates an output file stream to write to the file with the specified    * <code>name</code>.  If the second argument is <code>true</code>, then    * bytes will be written to the end of the file rather than the beginning.    * A new <code>OWFileDescriptor</code> object is created to represent this    * file connection.    * <p>    * First, if there is a security manager, its <code>checkWrite</code>    * method is called with <code>name</code> as its argument.    * <p>    * If the file exists but is a directory rather than a regular file, does    * not exist but cannot be created, or cannot be opened for any other    * reason then a <code>FileNotFoundException</code> is thrown.    *    * @param      owd    array of OneWireContainers that this Filesystem resides on    * @param     name    the system-dependent file name    * @param     append  if <code>true</code>, then bytes will be written    *                   to the end of the file rather than the beginning    * @exception  FileNotFoundException  if the file exists but is a directory    *                   rather than a regular file, does not exist but cannot    *                   be created, or cannot be opened for any other reason.    * @exception  SecurityException  if a security manager exists and its    *               <code>checkWrite</code> method denies write access    *               to the file.    */   public OWFileOutputStream(OneWireContainer[] owd, String name,                             boolean append)      throws OWFileNotFoundException   {      fd = new OWFileDescriptor(owd, name);      try      {         fd.create(append, false, false, -1, -1);      }      catch (OWFileNotFoundException e)      {         fd.free();         fd = null;         throw new OWFileNotFoundException(e.toString());      }   }   /**    * Creates a file output stream to write to the file represented by    * the specified <code>File</code> object. A new    * <code>OWFileDescriptor</code> object is created to represent this    * file connection.    * <p>    * First, if there is a security manager, its <code>checkWrite</code>    * method is called with the path represented by the <code>file</code>    * argument as its argument.    * <p>    * If the file exists but is a directory rather than a regular file, does    * not exist but cannot be created, or cannot be opened for any other    * reason then a <code>FileNotFoundException</code> is thrown.    *    * @param      file               the file to be opened for writing.    * @exception  FileNotFoundException  if the file exists but is a directory    *                   rather than a regular file, does not exist but cannot    *                   be created, or cannot be opened for any other reason    * @exception  SecurityException  if a security manager exists and its    *               <code>checkWrite</code> method denies write access    *               to the file.    * @see        java.io.File#getPath()    */   public OWFileOutputStream(OWFile file)      throws OWFileNotFoundException   {      try      {         fd = file.getFD();      }      catch (IOException e)      {         fd.free();         fd = null;         throw new OWFileNotFoundException(e.toString());      }      fd.open();   }   /**    * Creates an output file stream to write to the specified file    * descriptor, which represents an existing connection to an actual    * file in the Filesystem.    * <p>    * First, if there is a security manager, its <code>checkWrite</code>    * method is called with the file descriptor <code>fdObj</code>    * argument as its argument.    *    * @param      fdObj   the file descriptor to be opened for writing.    * @exception  SecurityException  if a security manager exists and its    *               <code>checkWrite</code> method denies    *               write access to the file descriptor.    */   public OWFileOutputStream(OWFileDescriptor fdObj)   {      if (fdObj == null)         throw new NullPointerException(            "1-Wire FileDescriptor provided is null");      fd = fdObj;   }   //--------   //-------- Write Methods   //--------   /**    * Writes the specified byte to this file output stream. Implements    * the <code>write</code> method of <code>OutputStream</code>.    *    * @param      b   the byte to be written.    * @exception  IOException  if an I/O error occurs.    */   public void write(int b)      throws IOException   {      if (fd != null)         fd.write(b);      else         throw new IOException("1-Wire FileDescriptor is null");   }   /**    * Writes <code>b.length</code> bytes from the specified byte array    * to this file output stream.    *    * @param      b   the data.    * @exception  IOException  if an I/O error occurs.    */   public void write(byte b [])      throws IOException   {      if (fd != null)         fd.write(b, 0, b.length);      else         throw new IOException("1-Wire FileDescriptor is null");   }   /**    * Writes <code>len</code> bytes from the specified byte array    * starting at offset <code>off</code> to this file output stream.    *    * @param      b     the data.    * @param      off   the start offset in the data.    * @param      len   the number of bytes to write.    * @exception  IOException  if an I/O error occurs.    */   public void write(byte b [], int off, int len)      throws IOException   {      if (fd != null)         fd.write(b, off, len);      else         throw new IOException("1-Wire FileDescriptor is null");   }   /**    * Closes this file output stream and releases any system resources    * associated with this stream. This file output stream may no longer    * be used for writing bytes.    *    * @exception  IOException  if an I/O error occurs.    */   public void close()      throws IOException   {      if (fd != null)         fd.close();      else         throw new IOException("1-Wire FileDescriptor is null");      fd = null;   }   /**    * Returns the file descriptor associated with this stream.    *    * @return  the <code>OWFileDescriptor</code> object that represents    *          the connection to the file in the Filesystem being used    *          by this <code>FileOutputStream</code> object.    *    * @exception  IOException  if an I/O error occurs.    * @see        com.dalsemi.onewire.application.file.OWFileDescriptor    */   public OWFileDescriptor getFD()      throws IOException   {      if (fd != null)         return fd;      else         throw new IOException("1-Wire FileDescriptor is null");   }   /**    * Cleans up the connection to the file, and ensures that the    * <code>close</code> method of this file output stream is    * called when there are no more references to this stream.    *    * @exception  IOException  if an I/O error occurs.    * @see        com.dalsemi.onewire.application.file.OWFileInputStream#close()    */   public void finalize()      throws IOException   {      if (fd != null)         fd.close();   }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -