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

📄 owfile.java

📁 这是一个以JAVA编写的程序,本人还没有试过,是一个简单的温度控制系统
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    *    * <p> The <em>parent</em> of an abstract pathname consists of the    * pathname's prefix, if any, and each name in the pathname's name    * sequence except for the last.  If the name sequence is empty then    * the pathname does not name a parent directory.    *    * @return  The abstract pathname of the parent directory named by this    *          abstract pathname, or <code>null</code> if this pathname    *          does not name a parent    */   public OWFile getParentFile()   {      return new OWFile(fd.getOneWireContainers(), fd.getParent());   }   /**    * Converts this abstract pathname into a pathname string.  The resulting    * string uses the {@link #separator default name-separator character} to    * separate the names in the name sequence.    *    * @return  The string form of this abstract pathname    */   public String getPath()   {      return fd.getPath();   }   //--------   //-------- Path Operations   //--------   /**    * Tests whether this abstract pathname is absolute.  The definition of    * absolute pathname is system dependent.  On UNIX systems, a pathname is    * absolute if its prefix is <code>"/"</code>.  On Win32 systems, a    * pathname is absolute if its prefix is a drive specifier followed by    * <code>"\\"</code>, or if its prefix is <code>"\\"</code>.    *    * @return  <code>true</code> if this abstract pathname is absolute,    *          <code>false</code> otherwise    */   public boolean isAbsolute()   {      // always absolute      return true;   }   /**    * Returns the absolute pathname string of this abstract pathname.    *    * <p> If this abstract pathname is already absolute, then the pathname    * string is simply returned as if by the <code>{@link #getPath}</code>    * method.  If this abstract pathname is the empty abstract pathname then    * the pathname string of the current user directory, which is named by the    * system property <code>user.dir</code>, is returned.  Otherwise this    * pathname is resolved in a system-dependent way.  On UNIX systems, a    * relative pathname is made absolute by resolving it against the current    * user directory.  On Win32 systems, a relative pathname is made absolute    * by resolving it against the current directory of the drive named by the    * pathname, if any; if not, it is resolved against the current user    * directory.    *    * @return  The absolute pathname string denoting the same file or    *          directory as this abstract pathname    *    * @see     java.io.File#isAbsolute()    */   public String getAbsolutePath()   {      return fd.getPath();   }   /**    * Returns the absolute form of this abstract pathname.  Equivalent to    * <code>new&nbsp;File(this.{@link #getAbsolutePath}())</code>.    *    * @return  The absolute abstract pathname denoting the same file or    *          directory as this abstract pathname    */   public OWFile getAbsoluteFile()   {      return new OWFile(fd.getOneWireContainers(), fd.getPath());   }   /**    * Returns the canonical pathname string of this abstract pathname.    *    * <p> The precise definition of canonical form is system-dependent, but    * canonical forms are always absolute.  Thus if this abstract pathname is    * relative it will be converted to absolute form as if by the <code>{@link    * #getAbsoluteFile}</code> method.    *    * <p> Every pathname that denotes an existing file or directory has a    * unique canonical form.  Every pathname that denotes a nonexistent file    * or directory also has a unique canonical form.  The canonical form of    * the pathname of a nonexistent file or directory may be different from    * the canonical form of the same pathname after the file or directory is    * created.  Similarly, the canonical form of the pathname of an existing    * file or directory may be different from the canonical form of the same    * pathname after the file or directory is deleted.    *    * @return  The canonical pathname string denoting the same file or    *          directory as this abstract pathname    *    * @throws  IOException    *          If an I/O error occurs, which is possible because the    *          construction of the canonical pathname may require    *          filesystem queries    *    * @since   JDK1.1    */   public String getCanonicalPath()      throws IOException   {      return fd.getPath();   }   /**    * Returns the canonical form of this abstract pathname.  Equivalent to    * <code>new&nbsp;File(this.{@link #getCanonicalPath}())</code>.    *    * @return  The canonical pathname string denoting the same file or    *          directory as this abstract pathname    *    * @throws  IOException    *          If an I/O error occurs, which is possible because the    *          construction of the canonical pathname may require    *          filesystem queries    */   public OWFile getCanonicalFile()      throws IOException   {      return new OWFile(fd.getOneWireContainers(), fd.getPath());   }   //--------   //-------- Attribute 'get' Methods   //--------   /**    * Tests whether the application can read the file denoted by this    * abstract pathname.    *    * @return  <code>true</code> if and only if the file specified by this    *          abstract pathname exists <em>and</em> can be read by the    *          application; <code>false</code> otherwise    */   public boolean canRead()   {      return fd.canRead();   }   /**    * Tests whether the application can modify to the file denoted by this    * abstract pathname.    *    * @return  <code>true</code> if and only if the Filesystem actually    *          contains a file denoted by this abstract pathname <em>and</em>    *          the application is allowed to write to the file;    *          <code>false</code> otherwise.    *    */   public boolean canWrite()   {      return fd.canWrite();   }   /**    * Tests whether the file denoted by this abstract pathname exists.    *    * @return  <code>true</code> if and only if the file denoted by this    *          abstract pathname exists; <code>false</code> otherwise    *    */   public boolean exists()   {      return fd.exists();   }   /**    * Tests whether the file denoted by this abstract pathname is a    * directory.    *    * @return <code>true</code> if and only if the file denoted by this    *          abstract pathname exists <em>and</em> is a directory;    *          <code>false</code> otherwise    */   public boolean isDirectory()   {      return fd.isDirectory();   }   /**    * Tests whether the file denoted by this abstract pathname is a normal    * file.  A file is <em>normal</em> if it is not a directory and, in    * addition, satisfies other system-dependent criteria.  Any non-directory    * file created by a Java application is guaranteed to be a normal file.    *    * @return  <code>true</code> if and only if the file denoted by this    *          abstract pathname exists <em>and</em> is a normal file;    *          <code>false</code> otherwise    */   public boolean isFile()   {      return fd.isFile();   }   /**    * Tests whether the file named by this abstract pathname is a hidden    * file.  The exact definition of <em>hidden</em> is system-dependent.  On    * UNIX systems, a file is considered to be hidden if its name begins with    * a period character (<code>'.'</code>).  On Win32 systems, a file is    * considered to be hidden if it has been marked as such in the filesystem.    *    * @return  <code>true</code> if and only if the file denoted by this    *          abstract pathname is hidden according to the conventions of the    *          underlying platform    */   public boolean isHidden()   {      return fd.isHidden();   }   /**    * Returns the time that the file denoted by this abstract pathname was    * last modified.    *    * @return  A <code>long</code> value representing the time the file was    *          last modified, measured in milliseconds since the epoch    *          (00:00:00 GMT, January 1, 1970), or <code>0L</code> if the    *          file does not exist or if an I/O error occurs    */   public long lastModified()   {      // not supported      return 0;   }   /**    * Returns the length of the file denoted by this abstract pathname.    *    * @return  The length, in bytes, of the file denoted by this abstract    *          pathname, or <code>0L</code> if the file does not exist    */   public long length()   {      return fd.length();   }   //--------   //-------- File Operation Methods   //--------   /**    * Atomically creates a new, empty file named by this abstract pathname if    * and only if a file with this name does not yet exist.  The check for the    * existence of the file and the creation of the file if it does not exist    * are a single operation that is atomic with respect to all other    * filesystem activities that might affect the file.    *    * @return  <code>true</code> if the named file does not exist and was    *          successfully created; <code>false</code> if the named file    *          already exists    *    * @throws  IOException    *          If an I/O error occurred    */   public boolean createNewFile()      throws IOException   {      return fd.createNewFile();   }   /**    * Deletes the file or directory denoted by this abstract pathname.  If    * this pathname denotes a directory, then the directory must be empty in    * order to be deleted.    *    * @return  <code>true</code> if and only if the file or directory is    *          successfully deleted; <code>false</code> otherwise    */   public boolean delete()   {      return fd.delete();   }   /**    * Returns an array of strings naming the files and directories in the    * directory denoted by this abstract pathname.    *    * <p> If this abstract pathname does not denote a directory, then this    * method returns <code>null</code>.  Otherwise an array of strings is    * returned, one for each file or directory in the directory.  Names    * denoting the directory itself and the directory's parent directory are    * not included in the result.  Each string is a file name rather than a    * complete path.    *    * <p> There is no guarantee that the name strings in the resulting array    * will appear in any specific order; they are not, in particular,    * guaranteed to appear in alphabetical order.    *    * @return  An array of strings naming the files and directories in the    *          directory denoted by this abstract pathname.  The array will be    *          empty if the directory is empty.  Returns <code>null</code> if    *          this abstract pathname does not denote a directory, or if an    *          I/O error occurs.    */   public String[] list()   {      if (isFile() ||!isDirectory())         return null;      else         return fd.list();   }   /**    * Returns an array of abstract pathnames denoting the files in the    * directory denoted by this abstract pathname.    *    * <p> If this abstract pathname does not denote a directory, then this    * method returns <code>null</code>.  Otherwise an array of    * <code>OWFile</code> objects is returned, one for each file or directory in    * the directory.  Pathnames denoting the directory itself and the    * directory's parent directory are not included in the result.  Each    * resulting abstract pathname is constructed from this abstract pathname    * using the <code>{@link #OWFile(com.dalsemi.onewire.application.file.OWFile, java.lang.String)    * OWFile(OWFile,&nbsp;String)}</code> constructor.  Therefore if this pathname    * is absolute then each resulting pathname is absolute; if this pathname    * is relative then each resulting pathname will be relative to the same    * directory.    *    * <p> There is no guarantee that the name strings in the resulting array    * will appear in any specific order; they are not, in particular,    * guaranteed to appear in alphabetical order.    *    * @return  An array of abstract pathnames denoting the files and    *          directories in the directory denoted by this abstract    *          pathname.  The array will be empty if the directory is    *          empty.  Returns <code>null</code> if this abstract pathname    *          does not denote a directory, or if an I/O error occurs.    */   public OWFile[] listFiles()   {      if (isFile() ||!isDirectory())         return null;      else      {         String[] str_list;         OWFile[] file_list;         String   new_path;         str_list  = fd.list();         file_list = new OWFile [str_list.length];         for (int i = 0; i < str_list.length; i++)         {            if ((fd.getPath() == null) || fd.getPath().endsWith("/"))               new_path = "/" + str_list [i];            else               new_path = fd.getPath() + separator + str_list [i];            file_list [i] = new OWFile(fd.getOneWireContainers(), new_path);         }         return file_list;      }   }   /**    * Creates the directory named by this abstract pathname.    *    * @return  <code>true</code> if and only if the directory was    *          created; <code>false</code> otherwise    */   public boolean mkdir()   {      try      {         fd.create(false, true, false, -1, -1);         return true;      }      catch (OWFileNotFoundException e)      {         return false;      }   }   /**    * Creates the directory named by this abstract pathname, including any    * necessary but nonexistent parent directories.  Note that if this    * operation fails it may have succeeded in creating some of the necessary    * parent directories.    *    * @return  <code>true</code> if and only if the directory was created,    *          along with all necessary parent directories; <code>false</code>    *          otherwise    */   public boolean mkdirs()   {      try      {         fd.create(false, true, true, -1, -1);         return true;      }      catch (OWFileNotFoundException e)      {         return false;      }   }   /**    * Renames the file denoted by this abstract pathname.    *    * @param  dest  The new abstract pathname for the named file    *    * @return  <code>true</code> if and only if the renaming succeeded;    *          <code>false</code> otherwise    *

⌨️ 快捷键说明

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