61 * <p> The conversion of a pathname string to or from an abstract pathname is |
61 * <p> The conversion of a pathname string to or from an abstract pathname is |
62 * inherently system-dependent. When an abstract pathname is converted into a |
62 * inherently system-dependent. When an abstract pathname is converted into a |
63 * pathname string, each name is separated from the next by a single copy of |
63 * pathname string, each name is separated from the next by a single copy of |
64 * the default <em>separator character</em>. The default name-separator |
64 * the default <em>separator character</em>. The default name-separator |
65 * character is defined by the system property <code>file.separator</code>, and |
65 * character is defined by the system property <code>file.separator</code>, and |
66 * is made available in the public static fields <code>{@link |
66 * is made available in the public static fields {@link |
67 * #separator}</code> and <code>{@link #separatorChar}</code> of this class. |
67 * #separator} and {@link #separatorChar} of this class. |
68 * When a pathname string is converted into an abstract pathname, the names |
68 * When a pathname string is converted into an abstract pathname, the names |
69 * within it may be separated by the default name-separator character or by any |
69 * within it may be separated by the default name-separator character or by any |
70 * other name-separator character that is supported by the underlying system. |
70 * other name-separator character that is supported by the underlying system. |
71 * |
71 * |
72 * <p> A pathname, whether abstract or in string form, may be either |
72 * <p> A pathname, whether abstract or in string form, may be either |
80 * virtual machine was invoked. |
80 * virtual machine was invoked. |
81 * |
81 * |
82 * <p> The <em>parent</em> of an abstract pathname may be obtained by invoking |
82 * <p> The <em>parent</em> of an abstract pathname may be obtained by invoking |
83 * the {@link #getParent} method of this class and consists of the pathname's |
83 * the {@link #getParent} method of this class and consists of the pathname's |
84 * prefix and each name in the pathname's name sequence except for the last. |
84 * prefix and each name in the pathname's name sequence except for the last. |
85 * Each directory's absolute pathname is an ancestor of any <tt>File</tt> |
85 * Each directory's absolute pathname is an ancestor of any {@code File} |
86 * object with an absolute abstract pathname which begins with the directory's |
86 * object with an absolute abstract pathname which begins with the directory's |
87 * absolute pathname. For example, the directory denoted by the abstract |
87 * absolute pathname. For example, the directory denoted by the abstract |
88 * pathname <tt>"/usr"</tt> is an ancestor of the directory denoted by the |
88 * pathname {@code "/usr"} is an ancestor of the directory denoted by the |
89 * pathname <tt>"/usr/local/bin"</tt>. |
89 * pathname {@code "/usr/local/bin"}. |
90 * |
90 * |
91 * <p> The prefix concept is used to handle root directories on UNIX platforms, |
91 * <p> The prefix concept is used to handle root directories on UNIX platforms, |
92 * and drive specifiers, root directories and UNC pathnames on Microsoft Windows platforms, |
92 * and drive specifiers, root directories and UNC pathnames on Microsoft Windows platforms, |
93 * as follows: |
93 * as follows: |
94 * |
94 * |
215 public static final char separatorChar = fs.getSeparator(); |
215 public static final char separatorChar = fs.getSeparator(); |
216 |
216 |
217 /** |
217 /** |
218 * The system-dependent default name-separator character, represented as a |
218 * The system-dependent default name-separator character, represented as a |
219 * string for convenience. This string contains a single character, namely |
219 * string for convenience. This string contains a single character, namely |
220 * <code>{@link #separatorChar}</code>. |
220 * {@link #separatorChar}. |
221 */ |
221 */ |
222 public static final String separator = "" + separatorChar; |
222 public static final String separator = "" + separatorChar; |
223 |
223 |
224 /** |
224 /** |
225 * The system-dependent path-separator character. This field is |
225 * The system-dependent path-separator character. This field is |
234 public static final char pathSeparatorChar = fs.getPathSeparator(); |
234 public static final char pathSeparatorChar = fs.getPathSeparator(); |
235 |
235 |
236 /** |
236 /** |
237 * The system-dependent path-separator character, represented as a string |
237 * The system-dependent path-separator character, represented as a string |
238 * for convenience. This string contains a single character, namely |
238 * for convenience. This string contains a single character, namely |
239 * <code>{@link #pathSeparatorChar}</code>. |
239 * {@link #pathSeparatorChar}. |
240 */ |
240 */ |
241 public static final String pathSeparator = "" + pathSeparatorChar; |
241 public static final String pathSeparator = "" + pathSeparatorChar; |
242 |
242 |
243 |
243 |
244 /* -- Constructors -- */ |
244 /* -- Constructors -- */ |
372 } |
372 } |
373 this.prefixLength = fs.prefixLength(this.path); |
373 this.prefixLength = fs.prefixLength(this.path); |
374 } |
374 } |
375 |
375 |
376 /** |
376 /** |
377 * Creates a new <tt>File</tt> instance by converting the given |
377 * Creates a new {@code File} instance by converting the given |
378 * <tt>file:</tt> URI into an abstract pathname. |
378 * {@code file:} URI into an abstract pathname. |
379 * |
379 * |
380 * <p> The exact form of a <tt>file:</tt> URI is system-dependent, hence |
380 * <p> The exact form of a {@code file:} URI is system-dependent, hence |
381 * the transformation performed by this constructor is also |
381 * the transformation performed by this constructor is also |
382 * system-dependent. |
382 * system-dependent. |
383 * |
383 * |
384 * <p> For a given abstract pathname <i>f</i> it is guaranteed that |
384 * <p> For a given abstract pathname <i>f</i> it is guaranteed that |
385 * |
385 * |
386 * <blockquote><tt> |
386 * <blockquote><code> |
387 * new File(</tt><i> f</i><tt>.{@link #toURI() toURI}()).equals(</tt><i> f</i><tt>.{@link #getAbsoluteFile() getAbsoluteFile}()) |
387 * new File(</code><i> f</i><code>.{@link #toURI() |
388 * </tt></blockquote> |
388 * toURI}()).equals(</code><i> f</i><code>.{@link #getAbsoluteFile() getAbsoluteFile}()) |
|
389 * </code></blockquote> |
389 * |
390 * |
390 * so long as the original abstract pathname, the URI, and the new abstract |
391 * so long as the original abstract pathname, the URI, and the new abstract |
391 * pathname are all created in (possibly different invocations of) the same |
392 * pathname are all created in (possibly different invocations of) the same |
392 * Java virtual machine. This relationship typically does not hold, |
393 * Java virtual machine. This relationship typically does not hold, |
393 * however, when a <tt>file:</tt> URI that is created in a virtual machine |
394 * however, when a {@code file:} URI that is created in a virtual machine |
394 * on one operating system is converted into an abstract pathname in a |
395 * on one operating system is converted into an abstract pathname in a |
395 * virtual machine on a different operating system. |
396 * virtual machine on a different operating system. |
396 * |
397 * |
397 * @param uri |
398 * @param uri |
398 * An absolute, hierarchical URI with a scheme equal to |
399 * An absolute, hierarchical URI with a scheme equal to |
399 * <tt>"file"</tt>, a non-empty path component, and undefined |
400 * {@code "file"}, a non-empty path component, and undefined |
400 * authority, query, and fragment components |
401 * authority, query, and fragment components |
401 * |
402 * |
402 * @throws NullPointerException |
403 * @throws NullPointerException |
403 * If <tt>uri</tt> is <tt>null</tt> |
404 * If {@code uri} is {@code null} |
404 * |
405 * |
405 * @throws IllegalArgumentException |
406 * @throws IllegalArgumentException |
406 * If the preconditions on the parameter do not hold |
407 * If the preconditions on the parameter do not hold |
407 * |
408 * |
408 * @see #toURI() |
409 * @see #toURI() |
531 |
532 |
532 /** |
533 /** |
533 * Returns the absolute pathname string of this abstract pathname. |
534 * Returns the absolute pathname string of this abstract pathname. |
534 * |
535 * |
535 * <p> If this abstract pathname is already absolute, then the pathname |
536 * <p> If this abstract pathname is already absolute, then the pathname |
536 * string is simply returned as if by the <code>{@link #getPath}</code> |
537 * string is simply returned as if by the {@link #getPath} |
537 * method. If this abstract pathname is the empty abstract pathname then |
538 * method. If this abstract pathname is the empty abstract pathname then |
538 * the pathname string of the current user directory, which is named by the |
539 * the pathname string of the current user directory, which is named by the |
539 * system property <code>user.dir</code>, is returned. Otherwise this |
540 * system property <code>user.dir</code>, is returned. Otherwise this |
540 * pathname is resolved in a system-dependent way. On UNIX systems, a |
541 * pathname is resolved in a system-dependent way. On UNIX systems, a |
541 * relative pathname is made absolute by resolving it against the current |
542 * relative pathname is made absolute by resolving it against the current |
579 * <p> A canonical pathname is both absolute and unique. The precise |
580 * <p> A canonical pathname is both absolute and unique. The precise |
580 * definition of canonical form is system-dependent. This method first |
581 * definition of canonical form is system-dependent. This method first |
581 * converts this pathname to absolute form if necessary, as if by invoking the |
582 * converts this pathname to absolute form if necessary, as if by invoking the |
582 * {@link #getAbsolutePath} method, and then maps it to its unique form in a |
583 * {@link #getAbsolutePath} method, and then maps it to its unique form in a |
583 * system-dependent way. This typically involves removing redundant names |
584 * system-dependent way. This typically involves removing redundant names |
584 * such as <tt>"."</tt> and <tt>".."</tt> from the pathname, resolving |
585 * such as {@code "."} and {@code ".."} from the pathname, resolving |
585 * symbolic links (on UNIX platforms), and converting drive letters to a |
586 * symbolic links (on UNIX platforms), and converting drive letters to a |
586 * standard case (on Microsoft Windows platforms). |
587 * standard case (on Microsoft Windows platforms). |
587 * |
588 * |
588 * <p> Every pathname that denotes an existing file or directory has a |
589 * <p> Every pathname that denotes an existing file or directory has a |
589 * unique canonical form. Every pathname that denotes a nonexistent file |
590 * unique canonical form. Every pathname that denotes a nonexistent file |
602 * construction of the canonical pathname may require |
603 * construction of the canonical pathname may require |
603 * filesystem queries |
604 * filesystem queries |
604 * |
605 * |
605 * @throws SecurityException |
606 * @throws SecurityException |
606 * If a required system property value cannot be accessed, or |
607 * If a required system property value cannot be accessed, or |
607 * if a security manager exists and its <code>{@link |
608 * if a security manager exists and its {@link |
608 * java.lang.SecurityManager#checkRead}</code> method denies |
609 * java.lang.SecurityManager#checkRead} method denies |
609 * read access to the file |
610 * read access to the file |
610 * |
611 * |
611 * @since 1.1 |
612 * @since 1.1 |
612 * @see Path#toRealPath |
613 * @see Path#toRealPath |
613 */ |
614 */ |
630 * construction of the canonical pathname may require |
631 * construction of the canonical pathname may require |
631 * filesystem queries |
632 * filesystem queries |
632 * |
633 * |
633 * @throws SecurityException |
634 * @throws SecurityException |
634 * If a required system property value cannot be accessed, or |
635 * If a required system property value cannot be accessed, or |
635 * if a security manager exists and its <code>{@link |
636 * if a security manager exists and its {@link |
636 * java.lang.SecurityManager#checkRead}</code> method denies |
637 * java.lang.SecurityManager#checkRead} method denies |
637 * read access to the file |
638 * read access to the file |
638 * |
639 * |
639 * @since 1.2 |
640 * @since 1.2 |
640 * @see Path#toRealPath |
641 * @see Path#toRealPath |
641 */ |
642 */ |
685 } |
686 } |
686 return new URL("file", "", slashify(getAbsolutePath(), isDirectory())); |
687 return new URL("file", "", slashify(getAbsolutePath(), isDirectory())); |
687 } |
688 } |
688 |
689 |
689 /** |
690 /** |
690 * Constructs a <tt>file:</tt> URI that represents this abstract pathname. |
691 * Constructs a {@code file:} URI that represents this abstract pathname. |
691 * |
692 * |
692 * <p> The exact form of the URI is system-dependent. If it can be |
693 * <p> The exact form of the URI is system-dependent. If it can be |
693 * determined that the file denoted by this abstract pathname is a |
694 * determined that the file denoted by this abstract pathname is a |
694 * directory, then the resulting URI will end with a slash. |
695 * directory, then the resulting URI will end with a slash. |
695 * |
696 * |
696 * <p> For a given abstract pathname <i>f</i>, it is guaranteed that |
697 * <p> For a given abstract pathname <i>f</i>, it is guaranteed that |
697 * |
698 * |
698 * <blockquote><tt> |
699 * <blockquote><code> |
699 * new {@link #File(java.net.URI) File}(</tt><i> f</i><tt>.toURI()).equals(</tt><i> f</i><tt>.{@link #getAbsoluteFile() getAbsoluteFile}()) |
700 * new {@link #File(java.net.URI) File}(</code><i> f</i><code>.toURI()).equals( |
700 * </tt></blockquote> |
701 * </code><i> f</i><code>.{@link #getAbsoluteFile() getAbsoluteFile}()) |
|
702 * </code></blockquote> |
701 * |
703 * |
702 * so long as the original abstract pathname, the URI, and the new abstract |
704 * so long as the original abstract pathname, the URI, and the new abstract |
703 * pathname are all created in (possibly different invocations of) the same |
705 * pathname are all created in (possibly different invocations of) the same |
704 * Java virtual machine. Due to the system-dependent nature of abstract |
706 * Java virtual machine. Due to the system-dependent nature of abstract |
705 * pathnames, however, this relationship typically does not hold when a |
707 * pathnames, however, this relationship typically does not hold when a |
706 * <tt>file:</tt> URI that is created in a virtual machine on one operating |
708 * {@code file:} URI that is created in a virtual machine on one operating |
707 * system is converted into an abstract pathname in a virtual machine on a |
709 * system is converted into an abstract pathname in a virtual machine on a |
708 * different operating system. |
710 * different operating system. |
709 * |
711 * |
710 * <p> Note that when this abstract pathname represents a UNC pathname then |
712 * <p> Note that when this abstract pathname represents a UNC pathname then |
711 * all components of the UNC (including the server name component) are encoded |
713 * all components of the UNC (including the server name component) are encoded |
714 * {@link Path#toUri toUri} method to encode the server name in the authority |
716 * {@link Path#toUri toUri} method to encode the server name in the authority |
715 * component of the resulting {@code URI}. The {@link #toPath toPath} method |
717 * component of the resulting {@code URI}. The {@link #toPath toPath} method |
716 * may be used to obtain a {@code Path} representing this abstract pathname. |
718 * may be used to obtain a {@code Path} representing this abstract pathname. |
717 * |
719 * |
718 * @return An absolute, hierarchical URI with a scheme equal to |
720 * @return An absolute, hierarchical URI with a scheme equal to |
719 * <tt>"file"</tt>, a path representing this abstract pathname, |
721 * {@code "file"}, a path representing this abstract pathname, |
720 * and undefined authority, query, and fragment components |
722 * and undefined authority, query, and fragment components |
721 * @throws SecurityException If a required system property value cannot |
723 * @throws SecurityException If a required system property value cannot |
722 * be accessed. |
724 * be accessed. |
723 * |
725 * |
724 * @see #File(java.net.URI) |
726 * @see #File(java.net.URI) |
751 * @return <code>true</code> if and only if the file specified by this |
753 * @return <code>true</code> if and only if the file specified by this |
752 * abstract pathname exists <em>and</em> can be read by the |
754 * abstract pathname exists <em>and</em> can be read by the |
753 * application; <code>false</code> otherwise |
755 * application; <code>false</code> otherwise |
754 * |
756 * |
755 * @throws SecurityException |
757 * @throws SecurityException |
756 * If a security manager exists and its <code>{@link |
758 * If a security manager exists and its {@link |
757 * java.lang.SecurityManager#checkRead(java.lang.String)}</code> |
759 * java.lang.SecurityManager#checkRead(java.lang.String)} |
758 * method denies read access to the file |
760 * method denies read access to the file |
759 */ |
761 */ |
760 public boolean canRead() { |
762 public boolean canRead() { |
761 SecurityManager security = System.getSecurityManager(); |
763 SecurityManager security = System.getSecurityManager(); |
762 if (security != null) { |
764 if (security != null) { |
779 * contains a file denoted by this abstract pathname <em>and</em> |
781 * contains a file denoted by this abstract pathname <em>and</em> |
780 * the application is allowed to write to the file; |
782 * the application is allowed to write to the file; |
781 * <code>false</code> otherwise. |
783 * <code>false</code> otherwise. |
782 * |
784 * |
783 * @throws SecurityException |
785 * @throws SecurityException |
784 * If a security manager exists and its <code>{@link |
786 * If a security manager exists and its {@link |
785 * java.lang.SecurityManager#checkWrite(java.lang.String)}</code> |
787 * java.lang.SecurityManager#checkWrite(java.lang.String)} |
786 * method denies write access to the file |
788 * method denies write access to the file |
787 */ |
789 */ |
788 public boolean canWrite() { |
790 public boolean canWrite() { |
789 SecurityManager security = System.getSecurityManager(); |
791 SecurityManager security = System.getSecurityManager(); |
790 if (security != null) { |
792 if (security != null) { |
802 * |
804 * |
803 * @return <code>true</code> if and only if the file or directory denoted |
805 * @return <code>true</code> if and only if the file or directory denoted |
804 * by this abstract pathname exists; <code>false</code> otherwise |
806 * by this abstract pathname exists; <code>false</code> otherwise |
805 * |
807 * |
806 * @throws SecurityException |
808 * @throws SecurityException |
807 * If a security manager exists and its <code>{@link |
809 * If a security manager exists and its {@link |
808 * java.lang.SecurityManager#checkRead(java.lang.String)}</code> |
810 * java.lang.SecurityManager#checkRead(java.lang.String)} |
809 * method denies read access to the file or directory |
811 * method denies read access to the file or directory |
810 */ |
812 */ |
811 public boolean exists() { |
813 public boolean exists() { |
812 SecurityManager security = System.getSecurityManager(); |
814 SecurityManager security = System.getSecurityManager(); |
813 if (security != null) { |
815 if (security != null) { |
832 * @return <code>true</code> if and only if the file denoted by this |
834 * @return <code>true</code> if and only if the file denoted by this |
833 * abstract pathname exists <em>and</em> is a directory; |
835 * abstract pathname exists <em>and</em> is a directory; |
834 * <code>false</code> otherwise |
836 * <code>false</code> otherwise |
835 * |
837 * |
836 * @throws SecurityException |
838 * @throws SecurityException |
837 * If a security manager exists and its <code>{@link |
839 * If a security manager exists and its {@link |
838 * java.lang.SecurityManager#checkRead(java.lang.String)}</code> |
840 * java.lang.SecurityManager#checkRead(java.lang.String)} |
839 * method denies read access to the file |
841 * method denies read access to the file |
840 */ |
842 */ |
841 public boolean isDirectory() { |
843 public boolean isDirectory() { |
842 SecurityManager security = System.getSecurityManager(); |
844 SecurityManager security = System.getSecurityManager(); |
843 if (security != null) { |
845 if (security != null) { |
865 * @return <code>true</code> if and only if the file denoted by this |
867 * @return <code>true</code> if and only if the file denoted by this |
866 * abstract pathname exists <em>and</em> is a normal file; |
868 * abstract pathname exists <em>and</em> is a normal file; |
867 * <code>false</code> otherwise |
869 * <code>false</code> otherwise |
868 * |
870 * |
869 * @throws SecurityException |
871 * @throws SecurityException |
870 * If a security manager exists and its <code>{@link |
872 * If a security manager exists and its {@link |
871 * java.lang.SecurityManager#checkRead(java.lang.String)}</code> |
873 * java.lang.SecurityManager#checkRead(java.lang.String)} |
872 * method denies read access to the file |
874 * method denies read access to the file |
873 */ |
875 */ |
874 public boolean isFile() { |
876 public boolean isFile() { |
875 SecurityManager security = System.getSecurityManager(); |
877 SecurityManager security = System.getSecurityManager(); |
876 if (security != null) { |
878 if (security != null) { |
892 * @return <code>true</code> if and only if the file denoted by this |
894 * @return <code>true</code> if and only if the file denoted by this |
893 * abstract pathname is hidden according to the conventions of the |
895 * abstract pathname is hidden according to the conventions of the |
894 * underlying platform |
896 * underlying platform |
895 * |
897 * |
896 * @throws SecurityException |
898 * @throws SecurityException |
897 * If a security manager exists and its <code>{@link |
899 * If a security manager exists and its {@link |
898 * java.lang.SecurityManager#checkRead(java.lang.String)}</code> |
900 * java.lang.SecurityManager#checkRead(java.lang.String)} |
899 * method denies read access to the file |
901 * method denies read access to the file |
900 * |
902 * |
901 * @since 1.2 |
903 * @since 1.2 |
902 */ |
904 */ |
903 public boolean isHidden() { |
905 public boolean isHidden() { |
926 * last modified, measured in milliseconds since the epoch |
928 * last modified, measured in milliseconds since the epoch |
927 * (00:00:00 GMT, January 1, 1970), or <code>0L</code> if the |
929 * (00:00:00 GMT, January 1, 1970), or <code>0L</code> if the |
928 * file does not exist or if an I/O error occurs |
930 * file does not exist or if an I/O error occurs |
929 * |
931 * |
930 * @throws SecurityException |
932 * @throws SecurityException |
931 * If a security manager exists and its <code>{@link |
933 * If a security manager exists and its {@link |
932 * java.lang.SecurityManager#checkRead(java.lang.String)}</code> |
934 * java.lang.SecurityManager#checkRead(java.lang.String)} |
933 * method denies read access to the file |
935 * method denies read access to the file |
934 */ |
936 */ |
935 public long lastModified() { |
937 public long lastModified() { |
936 SecurityManager security = System.getSecurityManager(); |
938 SecurityManager security = System.getSecurityManager(); |
937 if (security != null) { |
939 if (security != null) { |
957 * pathname, or <code>0L</code> if the file does not exist. Some |
959 * pathname, or <code>0L</code> if the file does not exist. Some |
958 * operating systems may return <code>0L</code> for pathnames |
960 * operating systems may return <code>0L</code> for pathnames |
959 * denoting system-dependent entities such as devices or pipes. |
961 * denoting system-dependent entities such as devices or pipes. |
960 * |
962 * |
961 * @throws SecurityException |
963 * @throws SecurityException |
962 * If a security manager exists and its <code>{@link |
964 * If a security manager exists and its {@link |
963 * java.lang.SecurityManager#checkRead(java.lang.String)}</code> |
965 * java.lang.SecurityManager#checkRead(java.lang.String)} |
964 * method denies read access to the file |
966 * method denies read access to the file |
965 */ |
967 */ |
966 public long length() { |
968 public long length() { |
967 SecurityManager security = System.getSecurityManager(); |
969 SecurityManager security = System.getSecurityManager(); |
968 if (security != null) { |
970 if (security != null) { |
995 * |
997 * |
996 * @throws IOException |
998 * @throws IOException |
997 * If an I/O error occurred |
999 * If an I/O error occurred |
998 * |
1000 * |
999 * @throws SecurityException |
1001 * @throws SecurityException |
1000 * If a security manager exists and its <code>{@link |
1002 * If a security manager exists and its {@link |
1001 * java.lang.SecurityManager#checkWrite(java.lang.String)}</code> |
1003 * java.lang.SecurityManager#checkWrite(java.lang.String)} |
1002 * method denies write access to the file |
1004 * method denies write access to the file |
1003 * |
1005 * |
1004 * @since 1.2 |
1006 * @since 1.2 |
1005 */ |
1007 */ |
1006 public boolean createNewFile() throws IOException { |
1008 public boolean createNewFile() throws IOException { |
1024 * |
1026 * |
1025 * @return <code>true</code> if and only if the file or directory is |
1027 * @return <code>true</code> if and only if the file or directory is |
1026 * successfully deleted; <code>false</code> otherwise |
1028 * successfully deleted; <code>false</code> otherwise |
1027 * |
1029 * |
1028 * @throws SecurityException |
1030 * @throws SecurityException |
1029 * If a security manager exists and its <code>{@link |
1031 * If a security manager exists and its {@link |
1030 * java.lang.SecurityManager#checkDelete}</code> method denies |
1032 * java.lang.SecurityManager#checkDelete} method denies |
1031 * delete access to the file |
1033 * delete access to the file |
1032 */ |
1034 */ |
1033 public boolean delete() { |
1035 public boolean delete() { |
1034 SecurityManager security = System.getSecurityManager(); |
1036 SecurityManager security = System.getSecurityManager(); |
1035 if (security != null) { |
1037 if (security != null) { |
1058 * the resulting protocol cannot be made to work reliably. The |
1060 * the resulting protocol cannot be made to work reliably. The |
1059 * {@link java.nio.channels.FileLock FileLock} |
1061 * {@link java.nio.channels.FileLock FileLock} |
1060 * facility should be used instead. |
1062 * facility should be used instead. |
1061 * |
1063 * |
1062 * @throws SecurityException |
1064 * @throws SecurityException |
1063 * If a security manager exists and its <code>{@link |
1065 * If a security manager exists and its {@link |
1064 * java.lang.SecurityManager#checkDelete}</code> method denies |
1066 * java.lang.SecurityManager#checkDelete} method denies |
1065 * delete access to the file |
1067 * delete access to the file |
1066 * |
1068 * |
1067 * @see #delete |
1069 * @see #delete |
1068 * |
1070 * |
1069 * @since 1.2 |
1071 * @since 1.2 |
1299 * |
1301 * |
1300 * @return <code>true</code> if and only if the directory was |
1302 * @return <code>true</code> if and only if the directory was |
1301 * created; <code>false</code> otherwise |
1303 * created; <code>false</code> otherwise |
1302 * |
1304 * |
1303 * @throws SecurityException |
1305 * @throws SecurityException |
1304 * If a security manager exists and its <code>{@link |
1306 * If a security manager exists and its {@link |
1305 * java.lang.SecurityManager#checkWrite(java.lang.String)}</code> |
1307 * java.lang.SecurityManager#checkWrite(java.lang.String)} |
1306 * method does not permit the named directory to be created |
1308 * method does not permit the named directory to be created |
1307 */ |
1309 */ |
1308 public boolean mkdir() { |
1310 public boolean mkdir() { |
1309 SecurityManager security = System.getSecurityManager(); |
1311 SecurityManager security = System.getSecurityManager(); |
1310 if (security != null) { |
1312 if (security != null) { |
1325 * @return <code>true</code> if and only if the directory was created, |
1327 * @return <code>true</code> if and only if the directory was created, |
1326 * along with all necessary parent directories; <code>false</code> |
1328 * along with all necessary parent directories; <code>false</code> |
1327 * otherwise |
1329 * otherwise |
1328 * |
1330 * |
1329 * @throws SecurityException |
1331 * @throws SecurityException |
1330 * If a security manager exists and its <code>{@link |
1332 * If a security manager exists and its {@link |
1331 * java.lang.SecurityManager#checkRead(java.lang.String)}</code> |
1333 * java.lang.SecurityManager#checkRead(java.lang.String)} |
1332 * method does not permit verification of the existence of the |
1334 * method does not permit verification of the existence of the |
1333 * named directory and all necessary parent directories; or if |
1335 * named directory and all necessary parent directories; or if |
1334 * the <code>{@link |
1336 * the {@link |
1335 * java.lang.SecurityManager#checkWrite(java.lang.String)}</code> |
1337 * java.lang.SecurityManager#checkWrite(java.lang.String)} |
1336 * method does not permit the named directory and all necessary |
1338 * method does not permit the named directory and all necessary |
1337 * parent directories to be created |
1339 * parent directories to be created |
1338 */ |
1340 */ |
1339 public boolean mkdirs() { |
1341 public boolean mkdirs() { |
1340 if (exists()) { |
1342 if (exists()) { |
1373 * |
1375 * |
1374 * @return <code>true</code> if and only if the renaming succeeded; |
1376 * @return <code>true</code> if and only if the renaming succeeded; |
1375 * <code>false</code> otherwise |
1377 * <code>false</code> otherwise |
1376 * |
1378 * |
1377 * @throws SecurityException |
1379 * @throws SecurityException |
1378 * If a security manager exists and its <code>{@link |
1380 * If a security manager exists and its {@link |
1379 * java.lang.SecurityManager#checkWrite(java.lang.String)}</code> |
1381 * java.lang.SecurityManager#checkWrite(java.lang.String)} |
1380 * method denies write access to either the old or new pathnames |
1382 * method denies write access to either the old or new pathnames |
1381 * |
1383 * |
1382 * @throws NullPointerException |
1384 * @throws NullPointerException |
1383 * If parameter <code>dest</code> is <code>null</code> |
1385 * If parameter <code>dest</code> is <code>null</code> |
1384 */ |
1386 */ |
1403 * |
1405 * |
1404 * <p> All platforms support file-modification times to the nearest second, |
1406 * <p> All platforms support file-modification times to the nearest second, |
1405 * but some provide more precision. The argument will be truncated to fit |
1407 * but some provide more precision. The argument will be truncated to fit |
1406 * the supported precision. If the operation succeeds and no intervening |
1408 * the supported precision. If the operation succeeds and no intervening |
1407 * operations on the file take place, then the next invocation of the |
1409 * operations on the file take place, then the next invocation of the |
1408 * <code>{@link #lastModified}</code> method will return the (possibly |
1410 * {@link #lastModified} method will return the (possibly |
1409 * truncated) <code>time</code> argument that was passed to this method. |
1411 * truncated) <code>time</code> argument that was passed to this method. |
1410 * |
1412 * |
1411 * @param time The new last-modified time, measured in milliseconds since |
1413 * @param time The new last-modified time, measured in milliseconds since |
1412 * the epoch (00:00:00 GMT, January 1, 1970) |
1414 * the epoch (00:00:00 GMT, January 1, 1970) |
1413 * |
1415 * |
1415 * <code>false</code> otherwise |
1417 * <code>false</code> otherwise |
1416 * |
1418 * |
1417 * @throws IllegalArgumentException If the argument is negative |
1419 * @throws IllegalArgumentException If the argument is negative |
1418 * |
1420 * |
1419 * @throws SecurityException |
1421 * @throws SecurityException |
1420 * If a security manager exists and its <code>{@link |
1422 * If a security manager exists and its {@link |
1421 * java.lang.SecurityManager#checkWrite(java.lang.String)}</code> |
1423 * java.lang.SecurityManager#checkWrite(java.lang.String)} |
1422 * method denies write access to the named file |
1424 * method denies write access to the named file |
1423 * |
1425 * |
1424 * @since 1.2 |
1426 * @since 1.2 |
1425 */ |
1427 */ |
1426 public boolean setLastModified(long time) { |
1428 public boolean setLastModified(long time) { |
1446 * |
1448 * |
1447 * @return <code>true</code> if and only if the operation succeeded; |
1449 * @return <code>true</code> if and only if the operation succeeded; |
1448 * <code>false</code> otherwise |
1450 * <code>false</code> otherwise |
1449 * |
1451 * |
1450 * @throws SecurityException |
1452 * @throws SecurityException |
1451 * If a security manager exists and its <code>{@link |
1453 * If a security manager exists and its {@link |
1452 * java.lang.SecurityManager#checkWrite(java.lang.String)}</code> |
1454 * java.lang.SecurityManager#checkWrite(java.lang.String)} |
1453 * method denies write access to the named file |
1455 * method denies write access to the named file |
1454 * |
1456 * |
1455 * @since 1.2 |
1457 * @since 1.2 |
1456 */ |
1458 */ |
1457 public boolean setReadOnly() { |
1459 public boolean setReadOnly() { |
1489 * @return <code>true</code> if and only if the operation succeeded. The |
1491 * @return <code>true</code> if and only if the operation succeeded. The |
1490 * operation will fail if the user does not have permission to change |
1492 * operation will fail if the user does not have permission to change |
1491 * the access permissions of this abstract pathname. |
1493 * the access permissions of this abstract pathname. |
1492 * |
1494 * |
1493 * @throws SecurityException |
1495 * @throws SecurityException |
1494 * If a security manager exists and its <code>{@link |
1496 * If a security manager exists and its {@link |
1495 * java.lang.SecurityManager#checkWrite(java.lang.String)}</code> |
1497 * java.lang.SecurityManager#checkWrite(java.lang.String)} |
1496 * method denies write access to the named file |
1498 * method denies write access to the named file |
1497 * |
1499 * |
1498 * @since 1.6 |
1500 * @since 1.6 |
1499 */ |
1501 */ |
1500 public boolean setWritable(boolean writable, boolean ownerOnly) { |
1502 public boolean setWritable(boolean writable, boolean ownerOnly) { |
1512 * A convenience method to set the owner's write permission for this abstract |
1514 * A convenience method to set the owner's write permission for this abstract |
1513 * pathname. On some platforms it may be possible to start the Java virtual |
1515 * pathname. On some platforms it may be possible to start the Java virtual |
1514 * machine with special privileges that allow it to modify files that |
1516 * machine with special privileges that allow it to modify files that |
1515 * disallow write operations. |
1517 * disallow write operations. |
1516 * |
1518 * |
1517 * <p> An invocation of this method of the form <tt>file.setWritable(arg)</tt> |
1519 * <p> An invocation of this method of the form {@code file.setWritable(arg)} |
1518 * behaves in exactly the same way as the invocation |
1520 * behaves in exactly the same way as the invocation |
1519 * |
1521 * |
1520 * <pre> |
1522 * <pre>{@code |
1521 * file.setWritable(arg, true) </pre> |
1523 * file.setWritable(arg, true) |
|
1524 * }</pre> |
1522 * |
1525 * |
1523 * @param writable |
1526 * @param writable |
1524 * If <code>true</code>, sets the access permission to allow write |
1527 * If <code>true</code>, sets the access permission to allow write |
1525 * operations; if <code>false</code> to disallow write operations |
1528 * operations; if <code>false</code> to disallow write operations |
1526 * |
1529 * |
1527 * @return <code>true</code> if and only if the operation succeeded. The |
1530 * @return <code>true</code> if and only if the operation succeeded. The |
1528 * operation will fail if the user does not have permission to |
1531 * operation will fail if the user does not have permission to |
1529 * change the access permissions of this abstract pathname. |
1532 * change the access permissions of this abstract pathname. |
1530 * |
1533 * |
1531 * @throws SecurityException |
1534 * @throws SecurityException |
1532 * If a security manager exists and its <code>{@link |
1535 * If a security manager exists and its {@link |
1533 * java.lang.SecurityManager#checkWrite(java.lang.String)}</code> |
1536 * java.lang.SecurityManager#checkWrite(java.lang.String)} |
1534 * method denies write access to the file |
1537 * method denies write access to the file |
1535 * |
1538 * |
1536 * @since 1.6 |
1539 * @since 1.6 |
1537 */ |
1540 */ |
1538 public boolean setWritable(boolean writable) { |
1541 public boolean setWritable(boolean writable) { |
1566 * <code>readable</code> is <code>false</code> and the underlying |
1569 * <code>readable</code> is <code>false</code> and the underlying |
1567 * file system does not implement a read permission, then the |
1570 * file system does not implement a read permission, then the |
1568 * operation will fail. |
1571 * operation will fail. |
1569 * |
1572 * |
1570 * @throws SecurityException |
1573 * @throws SecurityException |
1571 * If a security manager exists and its <code>{@link |
1574 * If a security manager exists and its {@link |
1572 * java.lang.SecurityManager#checkWrite(java.lang.String)}</code> |
1575 * java.lang.SecurityManager#checkWrite(java.lang.String)} |
1573 * method denies write access to the file |
1576 * method denies write access to the file |
1574 * |
1577 * |
1575 * @since 1.6 |
1578 * @since 1.6 |
1576 */ |
1579 */ |
1577 public boolean setReadable(boolean readable, boolean ownerOnly) { |
1580 public boolean setReadable(boolean readable, boolean ownerOnly) { |
1589 * A convenience method to set the owner's read permission for this abstract |
1592 * A convenience method to set the owner's read permission for this abstract |
1590 * pathname. On some platforms it may be possible to start the Java virtual |
1593 * pathname. On some platforms it may be possible to start the Java virtual |
1591 * machine with special privileges that allow it to read files that are |
1594 * machine with special privileges that allow it to read files that are |
1592 * marked as unreadable. |
1595 * marked as unreadable. |
1593 * |
1596 * |
1594 * <p>An invocation of this method of the form <tt>file.setReadable(arg)</tt> |
1597 * <p>An invocation of this method of the form {@code file.setReadable(arg)} |
1595 * behaves in exactly the same way as the invocation |
1598 * behaves in exactly the same way as the invocation |
1596 * |
1599 * |
1597 * <pre> |
1600 * <pre>{@code |
1598 * file.setReadable(arg, true) </pre> |
1601 * file.setReadable(arg, true) |
|
1602 * }</pre> |
1599 * |
1603 * |
1600 * @param readable |
1604 * @param readable |
1601 * If <code>true</code>, sets the access permission to allow read |
1605 * If <code>true</code>, sets the access permission to allow read |
1602 * operations; if <code>false</code> to disallow read operations |
1606 * operations; if <code>false</code> to disallow read operations |
1603 * |
1607 * |
1607 * <code>readable</code> is <code>false</code> and the underlying |
1611 * <code>readable</code> is <code>false</code> and the underlying |
1608 * file system does not implement a read permission, then the |
1612 * file system does not implement a read permission, then the |
1609 * operation will fail. |
1613 * operation will fail. |
1610 * |
1614 * |
1611 * @throws SecurityException |
1615 * @throws SecurityException |
1612 * If a security manager exists and its <code>{@link |
1616 * If a security manager exists and its {@link |
1613 * java.lang.SecurityManager#checkWrite(java.lang.String)}</code> |
1617 * java.lang.SecurityManager#checkWrite(java.lang.String)} |
1614 * method denies write access to the file |
1618 * method denies write access to the file |
1615 * |
1619 * |
1616 * @since 1.6 |
1620 * @since 1.6 |
1617 */ |
1621 */ |
1618 public boolean setReadable(boolean readable) { |
1622 public boolean setReadable(boolean readable) { |
1646 * <code>executable</code> is <code>false</code> and the underlying |
1650 * <code>executable</code> is <code>false</code> and the underlying |
1647 * file system does not implement an execute permission, then the |
1651 * file system does not implement an execute permission, then the |
1648 * operation will fail. |
1652 * operation will fail. |
1649 * |
1653 * |
1650 * @throws SecurityException |
1654 * @throws SecurityException |
1651 * If a security manager exists and its <code>{@link |
1655 * If a security manager exists and its {@link |
1652 * java.lang.SecurityManager#checkWrite(java.lang.String)}</code> |
1656 * java.lang.SecurityManager#checkWrite(java.lang.String)} |
1653 * method denies write access to the file |
1657 * method denies write access to the file |
1654 * |
1658 * |
1655 * @since 1.6 |
1659 * @since 1.6 |
1656 */ |
1660 */ |
1657 public boolean setExecutable(boolean executable, boolean ownerOnly) { |
1661 public boolean setExecutable(boolean executable, boolean ownerOnly) { |
1669 * A convenience method to set the owner's execute permission for this |
1673 * A convenience method to set the owner's execute permission for this |
1670 * abstract pathname. On some platforms it may be possible to start the Java |
1674 * abstract pathname. On some platforms it may be possible to start the Java |
1671 * virtual machine with special privileges that allow it to execute files |
1675 * virtual machine with special privileges that allow it to execute files |
1672 * that are not marked executable. |
1676 * that are not marked executable. |
1673 * |
1677 * |
1674 * <p>An invocation of this method of the form <tt>file.setExcutable(arg)</tt> |
1678 * <p>An invocation of this method of the form {@code file.setExcutable(arg)} |
1675 * behaves in exactly the same way as the invocation |
1679 * behaves in exactly the same way as the invocation |
1676 * |
1680 * |
1677 * <pre> |
1681 * <pre>{@code |
1678 * file.setExecutable(arg, true) </pre> |
1682 * file.setExecutable(arg, true) |
|
1683 * }</pre> |
1679 * |
1684 * |
1680 * @param executable |
1685 * @param executable |
1681 * If <code>true</code>, sets the access permission to allow execute |
1686 * If <code>true</code>, sets the access permission to allow execute |
1682 * operations; if <code>false</code> to disallow execute operations |
1687 * operations; if <code>false</code> to disallow execute operations |
1683 * |
1688 * |
1687 * <code>executable</code> is <code>false</code> and the underlying |
1692 * <code>executable</code> is <code>false</code> and the underlying |
1688 * file system does not implement an execute permission, then the |
1693 * file system does not implement an execute permission, then the |
1689 * operation will fail. |
1694 * operation will fail. |
1690 * |
1695 * |
1691 * @throws SecurityException |
1696 * @throws SecurityException |
1692 * If a security manager exists and its <code>{@link |
1697 * If a security manager exists and its {@link |
1693 * java.lang.SecurityManager#checkWrite(java.lang.String)}</code> |
1698 * java.lang.SecurityManager#checkWrite(java.lang.String)} |
1694 * method denies write access to the file |
1699 * method denies write access to the file |
1695 * |
1700 * |
1696 * @since 1.6 |
1701 * @since 1.6 |
1697 */ |
1702 */ |
1698 public boolean setExecutable(boolean executable) { |
1703 public boolean setExecutable(boolean executable) { |
1708 * |
1713 * |
1709 * @return <code>true</code> if and only if the abstract pathname exists |
1714 * @return <code>true</code> if and only if the abstract pathname exists |
1710 * <em>and</em> the application is allowed to execute the file |
1715 * <em>and</em> the application is allowed to execute the file |
1711 * |
1716 * |
1712 * @throws SecurityException |
1717 * @throws SecurityException |
1713 * If a security manager exists and its <code>{@link |
1718 * If a security manager exists and its {@link |
1714 * java.lang.SecurityManager#checkExec(java.lang.String)}</code> |
1719 * java.lang.SecurityManager#checkExec(java.lang.String)} |
1715 * method denies execute access to the file |
1720 * method denies execute access to the file |
1716 * |
1721 * |
1717 * @since 1.6 |
1722 * @since 1.6 |
1718 */ |
1723 */ |
1719 public boolean canExecute() { |
1724 public boolean canExecute() { |
1781 |
1786 |
1782 /** |
1787 /** |
1783 * Returns the size of the partition <a href="#partName">named</a> by this |
1788 * Returns the size of the partition <a href="#partName">named</a> by this |
1784 * abstract pathname. |
1789 * abstract pathname. |
1785 * |
1790 * |
1786 * @return The size, in bytes, of the partition or <tt>0L</tt> if this |
1791 * @return The size, in bytes, of the partition or {@code 0L} if this |
1787 * abstract pathname does not name a partition |
1792 * abstract pathname does not name a partition |
1788 * |
1793 * |
1789 * @throws SecurityException |
1794 * @throws SecurityException |
1790 * If a security manager has been installed and it denies |
1795 * If a security manager has been installed and it denies |
1791 * {@link RuntimePermission}<tt>("getFileSystemAttributes")</tt> |
1796 * {@link RuntimePermission}{@code ("getFileSystemAttributes")} |
1792 * or its {@link SecurityManager#checkRead(String)} method denies |
1797 * or its {@link SecurityManager#checkRead(String)} method denies |
1793 * read access to the file named by this abstract pathname |
1798 * read access to the file named by this abstract pathname |
1794 * |
1799 * |
1795 * @since 1.6 |
1800 * @since 1.6 |
1796 */ |
1801 */ |
1817 * inaccurate by any external I/O operations including those made |
1822 * inaccurate by any external I/O operations including those made |
1818 * on the system outside of this virtual machine. This method |
1823 * on the system outside of this virtual machine. This method |
1819 * makes no guarantee that write operations to this file system |
1824 * makes no guarantee that write operations to this file system |
1820 * will succeed. |
1825 * will succeed. |
1821 * |
1826 * |
1822 * @return The number of unallocated bytes on the partition or <tt>0L</tt> |
1827 * @return The number of unallocated bytes on the partition or {@code 0L} |
1823 * if the abstract pathname does not name a partition. This |
1828 * if the abstract pathname does not name a partition. This |
1824 * value will be less than or equal to the total file system size |
1829 * value will be less than or equal to the total file system size |
1825 * returned by {@link #getTotalSpace}. |
1830 * returned by {@link #getTotalSpace}. |
1826 * |
1831 * |
1827 * @throws SecurityException |
1832 * @throws SecurityException |
1828 * If a security manager has been installed and it denies |
1833 * If a security manager has been installed and it denies |
1829 * {@link RuntimePermission}<tt>("getFileSystemAttributes")</tt> |
1834 * {@link RuntimePermission}{@code ("getFileSystemAttributes")} |
1830 * or its {@link SecurityManager#checkRead(String)} method denies |
1835 * or its {@link SecurityManager#checkRead(String)} method denies |
1831 * read access to the file named by this abstract pathname |
1836 * read access to the file named by this abstract pathname |
1832 * |
1837 * |
1833 * @since 1.6 |
1838 * @since 1.6 |
1834 */ |
1839 */ |
1858 * after this call. It is likely to be made inaccurate by any external |
1863 * after this call. It is likely to be made inaccurate by any external |
1859 * I/O operations including those made on the system outside of this |
1864 * I/O operations including those made on the system outside of this |
1860 * virtual machine. This method makes no guarantee that write operations |
1865 * virtual machine. This method makes no guarantee that write operations |
1861 * to this file system will succeed. |
1866 * to this file system will succeed. |
1862 * |
1867 * |
1863 * @return The number of available bytes on the partition or <tt>0L</tt> |
1868 * @return The number of available bytes on the partition or {@code 0L} |
1864 * if the abstract pathname does not name a partition. On |
1869 * if the abstract pathname does not name a partition. On |
1865 * systems where this information is not available, this method |
1870 * systems where this information is not available, this method |
1866 * will be equivalent to a call to {@link #getFreeSpace}. |
1871 * will be equivalent to a call to {@link #getFreeSpace}. |
1867 * |
1872 * |
1868 * @throws SecurityException |
1873 * @throws SecurityException |
1869 * If a security manager has been installed and it denies |
1874 * If a security manager has been installed and it denies |
1870 * {@link RuntimePermission}<tt>("getFileSystemAttributes")</tt> |
1875 * {@link RuntimePermission}{@code ("getFileSystemAttributes")} |
1871 * or its {@link SecurityManager#checkRead(String)} method denies |
1876 * or its {@link SecurityManager#checkRead(String)} method denies |
1872 * read access to the file named by this abstract pathname |
1877 * read access to the file named by this abstract pathname |
1873 * |
1878 * |
1874 * @since 1.6 |
1879 * @since 1.6 |
1875 */ |
1880 */ |
1937 * machine. |
1942 * machine. |
1938 * </ol> |
1943 * </ol> |
1939 * |
1944 * |
1940 * This method provides only part of a temporary-file facility. To arrange |
1945 * This method provides only part of a temporary-file facility. To arrange |
1941 * for a file created by this method to be deleted automatically, use the |
1946 * for a file created by this method to be deleted automatically, use the |
1942 * <code>{@link #deleteOnExit}</code> method. |
1947 * {@link #deleteOnExit} method. |
1943 * |
1948 * |
1944 * <p> The <code>prefix</code> argument must be at least three characters |
1949 * <p> The <code>prefix</code> argument must be at least three characters |
1945 * long. It is recommended that the prefix be a short, meaningful string |
1950 * long. It is recommended that the prefix be a short, meaningful string |
1946 * such as <code>"hjb"</code> or <code>"mail"</code>. The |
1951 * such as <code>"hjb"</code> or <code>"mail"</code>. The |
1947 * <code>suffix</code> argument may be <code>null</code>, in which case the |
1952 * <code>suffix</code> argument may be <code>null</code>, in which case the |
1985 * characters |
1990 * characters |
1986 * |
1991 * |
1987 * @throws IOException If a file could not be created |
1992 * @throws IOException If a file could not be created |
1988 * |
1993 * |
1989 * @throws SecurityException |
1994 * @throws SecurityException |
1990 * If a security manager exists and its <code>{@link |
1995 * If a security manager exists and its {@link |
1991 * java.lang.SecurityManager#checkWrite(java.lang.String)}</code> |
1996 * java.lang.SecurityManager#checkWrite(java.lang.String)} |
1992 * method does not allow a file to be created |
1997 * method does not allow a file to be created |
1993 * |
1998 * |
1994 * @since 1.2 |
1999 * @since 1.2 |
1995 */ |
2000 */ |
1996 public static File createTempFile(String prefix, String suffix, |
2001 public static File createTempFile(String prefix, String suffix, |
2030 } |
2035 } |
2031 |
2036 |
2032 /** |
2037 /** |
2033 * Creates an empty file in the default temporary-file directory, using |
2038 * Creates an empty file in the default temporary-file directory, using |
2034 * the given prefix and suffix to generate its name. Invoking this method |
2039 * the given prefix and suffix to generate its name. Invoking this method |
2035 * is equivalent to invoking <code>{@link #createTempFile(java.lang.String, |
2040 * is equivalent to invoking {@link #createTempFile(java.lang.String, |
2036 * java.lang.String, java.io.File) |
2041 * java.lang.String, java.io.File) |
2037 * createTempFile(prefix, suffix, null)}</code>. |
2042 * createTempFile(prefix, suffix, null)}. |
2038 * |
2043 * |
2039 * <p> The {@link |
2044 * <p> The {@link |
2040 * java.nio.file.Files#createTempFile(String,String,java.nio.file.attribute.FileAttribute[]) |
2045 * java.nio.file.Files#createTempFile(String,String,java.nio.file.attribute.FileAttribute[]) |
2041 * Files.createTempFile} method provides an alternative method to create an |
2046 * Files.createTempFile} method provides an alternative method to create an |
2042 * empty file in the temporary-file directory. Files created by that method |
2047 * empty file in the temporary-file directory. Files created by that method |
2057 * characters |
2062 * characters |
2058 * |
2063 * |
2059 * @throws IOException If a file could not be created |
2064 * @throws IOException If a file could not be created |
2060 * |
2065 * |
2061 * @throws SecurityException |
2066 * @throws SecurityException |
2062 * If a security manager exists and its <code>{@link |
2067 * If a security manager exists and its {@link |
2063 * java.lang.SecurityManager#checkWrite(java.lang.String)}</code> |
2068 * java.lang.SecurityManager#checkWrite(java.lang.String)} |
2064 * method does not allow a file to be created |
2069 * method does not allow a file to be created |
2065 * |
2070 * |
2066 * @since 1.2 |
2071 * @since 1.2 |
2067 * @see java.nio.file.Files#createTempDirectory(String,FileAttribute[]) |
2072 * @see java.nio.file.Files#createTempDirectory(String,FileAttribute[]) |
2068 */ |
2073 */ |