Download 3d Files Free

0 views
Skip to first unread message

Kam Bergmann

unread,
Jan 21, 2024, 3:42:39 PM1/21/24
to tingropenhard
Method SummaryAll MethodsInstance MethodsConcrete MethodsDeprecated MethodsModifier and TypeMethodDescriptionprotected void_connectAction_()Initiates control connections and gets initial reply.protected void_connectAction_(Reader socketIsReader)Initiates control connections and gets initial reply.protected Socket_openDataConnection_(int command, String arg)Deprecated.(3.3) Use _openDataConnection_(FTPCmd, String) insteadprotected Socket_openDataConnection_(String command, String arg)Establishes a data connection with the FTP server, returning a Socket for the connection if successful.protected Socket_openDataConnection_(FTPCmd command, String arg)Establishes a data connection with the FTP server, returning a Socket for the connection if successful.protected void_parseExtendedPassiveModeReply(String reply) protected void_parsePassiveModeReply(String reply) protected boolean_retrieveFile(String command, String remote, OutputStream local) protected InputStream_retrieveFileStream(String command, String remote) protected boolean_storeFile(String command, String remote, InputStream local) protected OutputStream_storeFileStream(String command, String remote) booleanabort()Abort a transfer in progress.booleanallocate(int bytes)Reserve a number of bytes on the server for the next file transfer.booleanallocate(int bytes, int recordSize)Reserve space on the server for the next file transfer.booleanallocate(long bytes)Reserve a number of bytes on the server for the next file transfer.booleanallocate(long bytes, int recordSize)Reserve space on the server for the next file transfer.booleanappendFile(String remote, InputStream local)Appends to a file on the server with the given name, taking input from the given InputStream.OutputStreamappendFileStream(String remote)Returns an OutputStream through which data can be written to append to a file on the server with the given name.booleanchangeToParentDirectory()Change to the parent directory of the current working directory.booleanchangeWorkingDirectory(String pathname)Change the current working directory of the FTP session.booleancompletePendingCommand()There are a few FTPClient methods that do not complete the entire sequence of FTP commands to complete a transaction.voidconfigure(FTPClientConfig config)Implementation of the Configurable interface.booleandeleteFile(String pathname)Deletes a file on the FTP server.voiddisconnect()Closes the connection to the FTP server and restores connection parameters to the default values.booleandoCommand(String command, String params)Issue a command and wait for the reply.String[]doCommandAsStrings(String command, String params)Issue a command and wait for the reply, returning it as an array of strings.voidenterLocalActiveMode()Set the current data connection mode to ACTIVE_LOCAL_DATA_CONNECTION_MODE.voidenterLocalPassiveMode()Set the current data connection mode to PASSIVE_LOCAL_DATA_CONNECTION_MODE .booleanenterRemoteActiveMode(InetAddress host, int port)Set the current data connection mode to ACTIVE_REMOTE_DATA_CONNECTION .booleanenterRemotePassiveMode()Set the current data connection mode to PASSIVE_REMOTE_DATA_CONNECTION_MODE .booleanfeatures()Queries the server for supported features.StringfeatureValue(String feature)Queries the server for a supported feature, and returns its value (if any).String[]featureValues(String feature)Queries the server for a supported feature, and returns its values (if any).booleangetAutodetectUTF8()Tells if automatic server encoding detection is enabled or disabled.intgetBufferSize()Retrieve the current internal buffer size for buffered data streams.intgetControlKeepAliveReplyTimeout()Deprecated.Use getControlKeepAliveReplyTimeoutDuration().DurationgetControlKeepAliveReplyTimeoutDuration()Gets how long to wait for control keep-alive message replies.longgetControlKeepAliveTimeout()Deprecated.Use getControlKeepAliveTimeoutDuration().DurationgetControlKeepAliveTimeoutDuration()Gets the time to wait between sending control connection keepalive messages when processing file upload or download.CopyStreamListenergetCopyStreamListener()Obtain the currently active listener.int[]getCslDebug()Deprecated.3.7 For testing only; may be dropped or changed at any timeintgetDataConnectionMode()Returns the current data connection mode (one of the _DATA_CONNECTION_MODE constants).DurationgetDataTimeout()Gets the timeout to use when reading from the data connection.protected StringgetListArguments(String pathname) booleangetListHiddenFiles() StringgetModificationTime(String pathname)Issue the FTP MDTM command (not supported by all servers) to retrieve the last modification time of a file.StringgetPassiveHost()Returns the hostname or IP address (in the form of a string) returned by the server when entering passive mode.InetAddressgetPassiveLocalIPAddress()Set the local IP address in passive mode.intgetPassivePort()If in passive mode, returns the data port of the passive host.intgetReceiveDataSocketBufferSize()Retrieve the value to be used for the data socket SO_RCVBUF option.longgetRestartOffset()Fetches the restart offset.intgetSendDataSocketBufferSize()Retrieve the value to be used for the data socket SO_SNDBUF option.StringgetSize(String pathname)Issue the FTP SIZE command to the server for a given pathname.StringgetStatus()Issue the FTP STAT command to the server.StringgetStatus(String pathname)Issue the FTP STAT command to the server for a given pathname.StringgetSystemName()Deprecated.use getSystemType() insteadStringgetSystemType()Fetches the system type from the server and returns the string.booleanhasFeature(String feature)Queries the server for a supported feature.booleanhasFeature(String feature, String value)Queries the server for a supported feature with particular value, for example "AUTH SSL" or "AUTH TLS".booleanhasFeature(FTPCmd feature)Queries the server for a supported feature.FTPListParseEngineinitiateListParsing()Using the default autodetect mechanism, initialize an FTPListParseEngine object containing a raw file information for the current working directory on the server This information is obtained through the LIST command.FTPListParseEngineinitiateListParsing(String pathname)Using the default autodetect mechanism, initialize an FTPListParseEngine object containing a raw file information for the supplied directory.FTPListParseEngineinitiateListParsing(String parserKey, String pathname)Using the supplied parser key, initialize an FTPListParseEngine object containing a raw file information for the supplied directory.FTPListParseEngineinitiateMListParsing()Initiate list parsing for MLSD listings in the current working directory.FTPListParseEngineinitiateMListParsing(String pathname)Initiate list parsing for MLSD listings.booleanisIpAddressFromPasvResponse()Returns, whether the IP address from the server's response should be used.booleanisRemoteVerificationEnabled()Return whether or not verification of the remote host participating in data connections is enabled.booleanisUseEPSVwithIPv4()Whether to attempt using EPSV with IPv4.FTPFile[]listDirectories()Using the default system autodetect mechanism, obtain a list of directories contained in the current working directory.FTPFile[]listDirectories(String parent)Using the default system autodetect mechanism, obtain a list of directories contained in the specified directory.FTPFile[]listFiles()Using the default system autodetect mechanism, obtain a list of file information for the current working directory.FTPFile[]listFiles(String pathname)Using the default system autodetect mechanism, obtain a list of file information for the current working directory or for just a single file.FTPFile[]listFiles(String pathname, FTPFileFilter filter)Version of listFiles(String) which allows a filter to be provided.StringlistHelp()Fetches the system help information from the server and returns the full string.StringlistHelp(String command)Fetches the help information for a given command from the server and returns the full string.String[]listNames()Obtain a list of file names in the current working directory This information is obtained through the NLST command.String[]listNames(String pathname)Obtain a list of file names in a directory (or just the name of a given file, which is not particularly useful).booleanlogin(String user, String password)Login to the FTP server using the provided user and password.booleanlogin(String user, String password, String account)Login to the FTP server using the provided username, password, and account.booleanlogout()Logout of the FTP server by sending the QUIT command.booleanmakeDirectory(String pathname)Creates a new subdirectory on the FTP server in the current directory (if a relative pathname is given) or where specified (if an absolute pathname is given).CalendarmdtmCalendar(String pathname)Issue the FTP MDTM command (not supported by all servers) to retrieve the last modification time of a file.FTPFilemdtmFile(String pathname)Issue the FTP MDTM command (not supported by all servers) to retrieve the last modification time of a file.InstantmdtmInstant(String pathname)Issue the FTP MDTM command (not supported by all servers) to retrieve the last modification time of a file.FTPFile[]mlistDir()Generate a directory listing for the current directory using the MLSD command.FTPFile[]mlistDir(String pathname)Generate a directory listing using the MLSD command.FTPFile[]mlistDir(String pathname, FTPFileFilter filter)Generate a directory listing using the MLSD command.FTPFilemlistFile(String pathname)Get file details using the MLST commandStringprintWorkingDirectory()Returns the pathname of the current working directory.booleanreinitialize()Reinitialize the FTP session.booleanremoteAppend(String fileName)Initiate a server to server file transfer.booleanremoteRetrieve(String fileName)Initiate a server to server file transfer.booleanremoteStore(String fileName)Initiate a server to server file transfer.booleanremoteStoreUnique()Initiate a server to server file transfer.booleanremoteStoreUnique(String fileName)Initiate a server to server file transfer.booleanremoveDirectory(String pathname)Removes a directory on the FTP server (if empty).booleanrename(String from, String to)Renames a remote file.protected booleanrestart(long offset)Restart a STREAM_TRANSFER_MODE file transfer starting from the given offset.booleanretrieveFile(String remote, OutputStream local)Retrieves a named file from the server and writes it to the given OutputStream.InputStreamretrieveFileStream(String remote)Returns an InputStream from which a named file from the server can be read.booleansendNoOp()Sends a NOOP command to the FTP server.booleansendSiteCommand(String arguments)Send a site specific command.voidsetActiveExternalIPAddress(String ipAddress)Set the external IP address in active mode.voidsetActivePortRange(int minPort, int maxPort)Set the client side port range in active mode.voidsetAutodetectUTF8(boolean autodetect)Enables or disables automatic server encoding detection (only UTF-8 supported).voidsetBufferSize(int bufSize)Set the internal buffer size for buffered data streams.voidsetControlKeepAliveReplyTimeout(int timeoutMillis)Deprecated.Use setControlKeepAliveReplyTimeout(Duration).voidsetControlKeepAliveReplyTimeout(Duration timeout)Sets the duration to wait for control keep-alive message replies.voidsetControlKeepAliveTimeout(long controlIdleSeconds)Deprecated.Use setControlKeepAliveTimeout(Duration).voidsetControlKeepAliveTimeout(Duration controlIdle)Sets the duration to wait between sending control connection keepalive messages when processing file upload or download.voidsetCopyStreamListener(CopyStreamListener listener)Set the listener to be used when performing store/retrieve operations.voidsetDataTimeout(int timeoutMillis)Deprecated.Use setDataTimeout(Duration).voidsetDataTimeout(Duration timeout)Sets the timeout to use when reading from the data connection.booleansetFileStructure(int structure)Sets the file structure.booleansetFileTransferMode(int mode)Sets the transfer mode.booleansetFileType(int fileType)Sets the file type to be transferred.booleansetFileType(int fileType, int formatOrByteSize)Sets the file type to be transferred and the format.voidsetIpAddressFromPasvResponse(boolean usingIpAddressFromPasvResponse)Sets whether the IP address from the server's response should be used.voidsetListHiddenFiles(boolean listHiddenFiles)You can set this to true if you would like to get hidden files when listFiles() too.booleansetModificationTime(String pathname, String timeval)Issue the FTP MFMT command (not supported by all servers) which sets the last modified time of a file.voidsetParserFactory(FTPFileEntryParserFactory parserFactory)set the factory used for parser creation to the supplied factory object.voidsetPassiveLocalIPAddress(String ipAddress)Set the local IP address to use in passive mode.voidsetPassiveLocalIPAddress(InetAddress inetAddress)Set the local IP address to use in passive mode.voidsetPassiveNatWorkaround(boolean enabled)Deprecated.(3.6) use setPassiveNatWorkaroundStrategy(HostnameResolver) insteadvoidsetPassiveNatWorkaroundStrategy(FTPClient.HostnameResolver resolver)Sets the workaround strategy to replace the PASV mode reply addresses.voidsetReceieveDataSocketBufferSize(int bufSize)Sets the value to be used for the data socket SO_RCVBUF option.voidsetRemoteVerificationEnabled(boolean enable)Enable or disable verification that the remote host taking part of a data connection is the same as the host to which the control connection is attached.voidsetReportActiveExternalIPAddress(String ipAddress)Sets the external IP address to report in EPRT/PORT commands in active mode.voidsetRestartOffset(long offset)Sets the restart offset for file transfers.voidsetSendDataSocketBufferSize(int bufSize)Sets the value to be used for the data socket SO_SNDBUF option.voidsetUseEPSVwithIPv4(boolean selected)Set whether to use EPSV with IPv4.booleanstoreFile(String remote, InputStream local)Stores a file on the server using the given name and taking input from the given InputStream.OutputStreamstoreFileStream(String remote)Returns an OutputStream through which data can be written to store a file on the server using the given name.booleanstoreUniqueFile(InputStream local)Stores a file on the server using a unique name assigned by the server and taking input from the given InputStream.booleanstoreUniqueFile(String remote, InputStream local)Stores a file on the server using a unique name derived from the given name and taking input from the given InputStream.OutputStreamstoreUniqueFileStream()Returns an OutputStream through which data can be written to store a file on the server using a unique name assigned by the server.OutputStreamstoreUniqueFileStream(String remote)Returns an OutputStream through which data can be written to store a file on the server using a unique name derived from the given name.booleanstructureMount(String pathname)Issue the FTP SMNT command.Methods inherited from class org.apache.commons.net.ftp.FTP__getReplyNoReport, __noop, abor, acct, allo, allo, allo, allo, appe, cdup, cwd, dele, eprt, epsv, feat, getCommandSupport, getControlEncoding, getReply, getReplyCode, getReplyString, getReplyStrings, help, help, isStrictMultilineParsing, isStrictReplyParsing, list, list, mdtm, mfmt, mkd, mlsd, mlsd, mlst, mlst, mode, nlst, nlst, noop, pass, pasv, port, pwd, quit, rein, rest, retr, rmd, rnfr, rnto, sendCommand, sendCommand, sendCommand, sendCommand, sendCommand, sendCommand, setControlEncoding, setStrictMultilineParsing, setStrictReplyParsing, site, size, smnt, stat, stat, stor, stou, stou, stru, syst, type, type, userMethods inherited from class org.apache.commons.net.SocketClientaddProtocolCommandListener, applySocketAttributes, connect, connect, connect, connect, connect, connect, createCommandSupport, fireCommandSent, fireReplyReceived, getCharset, getCharsetName, getConnectTimeout, getDefaultPort, getDefaultTimeout, getKeepAlive, getLocalAddress, getLocalPort, getProxy, getReceiveBufferSize, getRemoteAddress, getRemoteInetSocketAddress, getRemotePort, getSendBufferSize, getServerSocketFactory, getSoLinger, getSoTimeout, getTcpNoDelay, isAvailable, isConnected, removeProtocolCommandListener, setCharset, setConnectTimeout, setDefaultPort, setDefaultTimeout, setKeepAlive, setProxy, setReceiveBufferSize, setSendBufferSize, setServerSocketFactory, setSocketFactory, setSoLinger, setSoTimeout, setTcpNoDelay, verifyRemoteMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

In most cases, the methods defined here will delegate to the associated file system provider to perform the file operations.Since:1.7Method SummaryAll Methods Static Methods Concrete Methods Modifier and TypeMethod and Descriptionstatic longcopy(InputStream in, Path target, CopyOption... options)Copies all bytes from an input stream to a file.static longcopy(Path source, OutputStream out)Copies all bytes from a file to an output stream.static Pathcopy(Path source, Path target, CopyOption... options)Copy a file to a target file.static PathcreateDirectories(Path dir, FileAttribute... attrs)Creates a directory by creating all nonexistent parent directories first.static PathcreateDirectory(Path dir, FileAttribute... attrs)Creates a new directory.static PathcreateFile(Path path, FileAttribute... attrs)Creates a new and empty file, failing if the file already exists.static PathcreateLink(Path link, Path existing)Creates a new link (directory entry) for an existing file (optional operation).static PathcreateSymbolicLink(Path link, Path target, FileAttribute... attrs)Creates a symbolic link to a target (optional operation).static PathcreateTempDirectory(Path dir, String prefix, FileAttribute... attrs)Creates a new directory in the specified directory, using the given prefix to generate its name.static PathcreateTempDirectory(String prefix, FileAttribute... attrs)Creates a new directory in the default temporary-file directory, using the given prefix to generate its name.static PathcreateTempFile(Path dir, String prefix, String suffix, FileAttribute... attrs)Creates a new empty file in the specified directory, using the given prefix and suffix strings to generate its name.static PathcreateTempFile(String prefix, String suffix, FileAttribute... attrs)Creates an empty file in the default temporary-file directory, using the given prefix and suffix to generate its name.static voiddelete(Path path)Deletes a file.static booleandeleteIfExists(Path path)Deletes a file if it exists.static booleanexists(Path path, LinkOption... options)Tests whether a file exists.static Streamfind(Path start, int maxDepth, BiPredicate matcher, FileVisitOption... options)Return a Stream that is lazily populated with Path by searching for files in a file tree rooted at a given starting file.static ObjectgetAttribute(Path path, String attribute, LinkOption... options)Reads the value of a file attribute.static
VgetFileAttributeView(Path path, Class type, LinkOption... options)Returns a file attribute view of a given type.static FileStoregetFileStore(Path path)Returns the FileStore representing the file store where a file is located.static FileTimegetLastModifiedTime(Path path, LinkOption... options)Returns a file's last modified time.static UserPrincipalgetOwner(Path path, LinkOption... options)Returns the owner of a file.static SetgetPosixFilePermissions(Path path, LinkOption... options)Returns a file's POSIX file permissions.static booleanisDirectory(Path path, LinkOption... options)Tests whether a file is a directory.static booleanisExecutable(Path path)Tests whether a file is executable.static booleanisHidden(Path path)Tells whether or not a file is considered hidden.static booleanisReadable(Path path)Tests whether a file is readable.static booleanisRegularFile(Path path, LinkOption... options)Tests whether a file is a regular file with opaque content.static booleanisSameFile(Path path, Path path2)Tests if two paths locate the same file.static booleanisSymbolicLink(Path path)Tests whether a file is a symbolic link.static booleanisWritable(Path path)Tests whether a file is writable.static Streamlines(Path path)Read all lines from a file as a Stream.static Streamlines(Path path, Charset cs)Read all lines from a file as a Stream.static Streamlist(Path dir)Return a lazily populated Stream, the elements of which are the entries in the directory.static Pathmove(Path source, Path target, CopyOption... options)Move or rename a file to a target file.static BufferedReadernewBufferedReader(Path path)Opens a file for reading, returning a BufferedReader to read text from the file in an efficient manner.static BufferedReadernewBufferedReader(Path path, Charset cs)Opens a file for reading, returning a BufferedReader that may be used to read text from the file in an efficient manner.static BufferedWriternewBufferedWriter(Path path, Charset cs, OpenOption... options)Opens or creates a file for writing, returning a BufferedWriter that may be used to write text to the file in an efficient manner.static BufferedWriternewBufferedWriter(Path path, OpenOption... options)Opens or creates a file for writing, returning a BufferedWriter to write text to the file in an efficient manner.static SeekableByteChannelnewByteChannel(Path path, OpenOption... options)Opens or creates a file, returning a seekable byte channel to access the file.static SeekableByteChannelnewByteChannel(Path path, Set... attrs)Opens or creates a file, returning a seekable byte channel to access the file.static DirectoryStreamnewDirectoryStream(Path dir)Opens a directory, returning a DirectoryStream to iterate over all entries in the directory.static DirectoryStreamnewDirectoryStream(Path dir, DirectoryStream.Filter... attrs) throws IOExceptionOpens or creates a file, returning a seekable byte channel to access the file. The options parameter determines how the file is opened. The READ and WRITE options determine if the file should be opened for reading and/or writing. If neither option (or the APPEND option) is present then the file is opened for reading. By default reading or writing commence at the beginning of the file. In the addition to READ and WRITE, the following options may be present: Option Description APPEND If this option is present then the file is opened for writing and each invocation of the channel's write method first advances the position to the end of the file and then writes the requested data. Whether the advancement of the position and the writing of the data are done in a single atomic operation is system-dependent and therefore unspecified. This option may not be used in conjunction with the READ or TRUNCATE_EXISTING options. TRUNCATE_EXISTING If this option is present then the existing file is truncated to a size of 0 bytes. This option is ignored when the file is opened only for reading. CREATE_NEW If this option is present then a new file is created, failing if the file already exists or is a symbolic link. When creating a file the check for the existence of the file and the creation of the file if it does not exist is atomic with respect to other file system operations. This option is ignored when the file is opened only for reading. CREATE If this option is present then an existing file is opened if it exists, otherwise a new file is created. This option is ignored if the CREATE_NEW option is also present or the file is opened only for reading. DELETE_ON_CLOSE When this option is present then the implementation makes a best effort attempt to delete the file when closed by the close method. If the close method is not invoked then a best effort attempt is made to delete the file when the Java virtual machine terminates. SPARSE When creating a new file this option is a hint that the new file will be sparse. This option is ignored when not creating a new file. SYNC Requires that every update to the file's content or metadata be written synchronously to the underlying storage device. (see Synchronized I/O file integrity). DSYNC Requires that every update to the file's content be written synchronously to the underlying storage device. (see Synchronized I/O file integrity). An implementation may also support additional implementation specific options. The attrs parameter is optional file-attributes to set atomically when a new file is created. In the case of the default provider, the returned seekable byte channel is a FileChannel. Usage Examples: Path path = ... // open file for reading ReadableByteChannel rbc = Files.newByteChannel(path, EnumSet.of(READ))); // open file for writing to the end of an existing file, creating // the file if it doesn't already exist WritableByteChannel wbc = Files.newByteChannel(path, EnumSet.of(CREATE,APPEND)); // create file with initial permissions, opening it for both reading and writing FileAttribute perms = ... SeekableByteChannel sbc = Files.newByteChannel(path, EnumSet.of(CREATE_NEW,READ,WRITE), perms); Parameters:path - the path to the file to open or createoptions - options specifying how the file is openedattrs - an optional list of file attributes to set atomically when creating the fileReturns:a new seekable byte channelThrows:IllegalArgumentException - if the set contains an invalid combination of optionsUnsupportedOperationException - if an unsupported open option is specified or the array contains attributes that cannot be set atomically when creating the fileFileAlreadyExistsException - if a file of that name already exists and the CREATE_NEW option is specified (optional specific exception)IOException - if an I/O error occursSecurityException - In the case of the default provider, and a security manager is installed, the checkRead method is invoked to check read access to the path if the file is opened for reading. The checkWrite method is invoked to check write access to the path if the file is opened for writing. The checkDelete method is invoked to check delete access if the file is opened with the DELETE_ON_CLOSE option.See Also:FileChannel.open(Path,Set,FileAttribute[])newByteChannelpublic static SeekableByteChannel newByteChannel(Path path, OpenOption... options) throws IOExceptionOpens or creates a file, returning a seekable byte channel to access the file. This method opens or creates a file in exactly the manner specified by the newByteChannel method.Parameters:path - the path to the file to open or createoptions - options specifying how the file is openedReturns:a new seekable byte channelThrows:IllegalArgumentException - if the set contains an invalid combination of optionsUnsupportedOperationException - if an unsupported open option is specifiedFileAlreadyExistsException - if a file of that name already exists and the CREATE_NEW option is specified (optional specific exception)IOException - if an I/O error occursSecurityException - In the case of the default provider, and a security manager is installed, the checkRead method is invoked to check read access to the path if the file is opened for reading. The checkWrite method is invoked to check write access to the path if the file is opened for writing. The checkDelete method is invoked to check delete access if the file is opened with the DELETE_ON_CLOSE option.See Also:FileChannel.open(Path,OpenOption[])newDirectoryStreampublic static DirectoryStream newDirectoryStream(Path dir) throws IOExceptionOpens a directory, returning a DirectoryStream to iterate over all entries in the directory. The elements returned by the directory stream's iterator are of type Path, each one representing an entry in the directory. The Path objects are obtained as if by resolving the name of the directory entry against dir. When not using the try-with-resources construct, then directory stream's close method should be invoked after iteration is completed so as to free any resources held for the open directory. When an implementation supports operations on entries in the directory that execute in a race-free manner then the returned directory stream is a SecureDirectoryStream.Parameters:dir - the path to the directoryReturns:a new and open DirectoryStream objectThrows:NotDirectoryException - if the file could not otherwise be opened because it is not a directory (optional specific exception)IOException - if an I/O error occursSecurityException - In the case of the default provider, and a security manager is installed, the checkRead method is invoked to check read access to the directory.newDirectoryStreampublic static DirectoryStream newDirectoryStream(Path dir, String glob) throws IOExceptionOpens a directory, returning a DirectoryStream to iterate over the entries in the directory. The elements returned by the directory stream's iterator are of type Path, each one representing an entry in the directory. The Path objects are obtained as if by resolving the name of the directory entry against dir. The entries returned by the iterator are filtered by matching the String representation of their file names against the given globbing pattern. For example, suppose we want to iterate over the files ending with ".java" in a directory: Path dir = ... try (DirectoryStream stream = Files.newDirectoryStream(dir, "*.java")) : The globbing pattern is specified by the getPathMatcher method. When not using the try-with-resources construct, then directory stream's close method should be invoked after iteration is completed so as to free any resources held for the open directory. When an implementation supports operations on entries in the directory that execute in a race-free manner then the returned directory stream is a SecureDirectoryStream.Parameters:dir - the path to the directoryglob - the glob patternReturns:a new and open DirectoryStream objectThrows:PatternSyntaxException - if the pattern is invalidNotDirectoryException - if the file could not otherwise be opened because it is not a directory (optional specific exception)IOException - if an I/O error occursSecurityException - In the case of the default provider, and a security manager is installed, the checkRead method is invoked to check read access to the directory.newDirectoryStreampublic static DirectoryStream newDirectoryStream(Path dir, DirectoryStream.Filter... attrs) throws IOExceptionCreates a new and empty file, failing if the file already exists. The check for the existence of the file and the creation of the new file if it does not exist are a single operation that is atomic with respect to all other filesystem activities that might affect the directory. The attrs parameter is optional file-attributes to set atomically when creating the file. Each attribute is identified by its name. If more than one attribute of the same name is included in the array then all but the last occurrence is ignored.Parameters:path - the path to the file to createattrs - an optional list of file attributes to set atomically when creating the fileReturns:the fileThrows:UnsupportedOperationException - if the array contains an attribute that cannot be set atomically when creating the fileFileAlreadyExistsException - if a file of that name already exists (optional specific exception)IOException - if an I/O error occurs or the parent directory does not existSecurityException - In the case of the default provider, and a security manager is installed, the checkWrite method is invoked to check write access to the new file.createDirectorypublic static Path createDirectory(Path dir, FileAttribute... attrs) throws IOExceptionCreates a new directory. The check for the existence of the file and the creation of the directory if it does not exist are a single operation that is atomic with respect to all other filesystem activities that might affect the directory. The createDirectories method should be used where it is required to create all nonexistent parent directories first. The attrs parameter is optional file-attributes to set atomically when creating the directory. Each attribute is identified by its name. If more than one attribute of the same name is included in the array then all but the last occurrence is ignored.Parameters:dir - the directory to createattrs - an optional list of file attributes to set atomically when creating the directoryReturns:the directoryThrows:UnsupportedOperationException - if the array contains an attribute that cannot be set atomically when creating the directoryFileAlreadyExistsException - if a directory could not otherwise be created because a file of that name already exists (optional specific exception)IOException - if an I/O error occurs or the parent directory does not existSecurityException - In the case of the default provider, and a security manager is installed, the checkWrite method is invoked to check write access to the new directory.createDirectoriespublic static Path createDirectories(Path dir, FileAttribute... attrs) throws IOExceptionCreates a directory by creating all nonexistent parent directories first. Unlike the createDirectory method, an exception is not thrown if the directory could not be created because it already exists. The attrs parameter is optional file-attributes to set atomically when creating the nonexistent directories. Each file attribute is identified by its name. If more than one attribute of the same name is included in the array then all but the last occurrence is ignored. If this method fails, then it may do so after creating some, but not all, of the parent directories.Parameters:dir - the directory to createattrs - an optional list of file attributes to set atomically when creating the directoryReturns:the directoryThrows:UnsupportedOperationException - if the array contains an attribute that cannot be set atomically when creating the directoryFileAlreadyExistsException - if dir exists but is not a directory (optional specific exception)IOException - if an I/O error occursSecurityException - in the case of the default provider, and a security manager is installed, the checkWrite method is invoked prior to attempting to create a directory and its checkRead is invoked for each parent directory that is checked. If dir is not an absolute path then its toAbsolutePath may need to be invoked to get its absolute path. This may invoke the security manager's checkPropertyAccess method to check access to the system property user.dircreateTempFilepublic static Path createTempFile(Path dir, String prefix, String suffix, FileAttribute... attrs) throws IOExceptionCreates a new empty file in the specified directory, using the given prefix and suffix strings to generate its name. The resulting Path is associated with the same FileSystem as the given directory. The details as to how the name of the file is constructed is implementation dependent and therefore not specified. Where possible the prefix and suffix are used to construct candidate names in the same manner as the File.createTempFile(String,String,File) method. As with the File.createTempFile methods, this method is only part of a temporary-file facility. Where used as a work files, the resulting file may be opened using the DELETE_ON_CLOSE option so that the file is deleted when the appropriate close method is invoked. Alternatively, a shutdown-hook, or the File.deleteOnExit() mechanism may be used to delete the file automatically. The attrs parameter is optional file-attributes to set atomically when creating the file. Each attribute is identified by its name. If more than one attribute of the same name is included in the array then all but the last occurrence is ignored. When no file attributes are specified, then the resulting file may have more restrictive access permissions to files created by the File.createTempFile(String,String,File) method.Parameters:dir - the path to directory in which to create the fileprefix - the prefix string to be used in generating the file's name; may be nullsuffix - the suffix string to be used in generating the file's name; may be null, in which case ".tmp" is usedattrs - an optional list of file attributes to set atomically when creating the fileReturns:the path to the newly created file that did not exist before this method was invokedThrows:IllegalArgumentException - if the prefix or suffix parameters cannot be used to generate a candidate file nameUnsupportedOperationException - if the array contains an attribute that cannot be set atomically when creating the directoryIOException - if an I/O error occurs or dir does not existSecurityException - In the case of the default provider, and a security manager is installed, the checkWrite method is invoked to check write access to the file.createTempFilepublic static Path createTempFile(String prefix, String suffix, FileAttribute... attrs) throws IOExceptionCreates an empty file in the default temporary-file directory, using the given prefix and suffix to generate its name. The resulting Path is associated with the default FileSystem. This method works in exactly the manner specified by the createTempFile(Path,String,String,FileAttribute[]) method for the case that the dir parameter is the temporary-file directory.Parameters:prefix - the prefix string to be used in generating the file's name; may be nullsuffix - the suffix string to be used in generating the file's name; may be null, in which case ".tmp" is usedattrs - an optional list of file attributes to set atomically when creating the fileReturns:the path to the newly created file that did not exist before this method was invokedThrows:IllegalArgumentException - if the prefix or suffix parameters cannot be used to generate a candidate file nameUnsupportedOperationException - if the array contains an attribute that cannot be set atomically when creating the directoryIOException - if an I/O error occurs or the temporary-file directory does not existSecurityException - In the case of the default provider, and a security manager is installed, the checkWrite method is invoked to check write access to the file.createTempDirectorypublic static Path createTempDirectory(Path dir, String prefix, FileAttribute... attrs) throws IOExceptionCreates a new directory in the specified directory, using the given prefix to generate its name. The resulting Path is associated with the same FileSystem as the given directory. The details as to how the name of the directory is constructed is implementation dependent and therefore not specified. Where possible the prefix is used to construct candidate names. As with the createTempFile methods, this method is only part of a temporary-file facility. A shutdown-hook, or the File.deleteOnExit() mechanism may be used to delete the directory automatically. The attrs parameter is optional file-attributes to set atomically when creating the directory. Each attribute is identified by its name. If more than one attribute of the same name is included in the array then all but the last occurrence is ignored.Parameters:dir - the path to directory in which to create the directoryprefix - the prefix string to be used in generating the directory's name; may be nullattrs - an optional list of file attributes to set atomically when creating the directoryReturns:the path to the newly created directory that did not exist before this method was invokedThrows:IllegalArgumentException - if the prefix cannot be used to generate a candidate directory nameUnsupportedOperationException - if the array contains an attribute that cannot be set atomically when creating the directoryIOException - if an I/O error occurs or dir does not existSecurityException - In the case of the default provider, and a security manager is installed, the checkWrite method is invoked to check write access when creating the directory.createTempDirectorypublic static Path createTempDirectory(String prefix, FileAttribute... attrs) throws IOExceptionCreates a new directory in the default temporary-file directory, using the given prefix to generate its name. The resulting Path is associated with the default FileSystem. This method works in exactly the manner specified by createTempDirectory(Path,String,FileAttribute[]) method for the case that the dir parameter is the temporary-file directory.Parameters:prefix - the prefix string to be used in generating the directory's name; may be nullattrs - an optional list of file attributes to set atomically when creating the directoryReturns:the path to the newly created directory that did not exist before this method was invokedThrows:IllegalArgumentException - if the prefix cannot be used to generate a candidate directory nameUnsupportedOperationException - if the array contains an attribute that cannot be set atomically when creating the directoryIOException - if an I/O error occurs or the temporary-file directory does not existSecurityException - In the case of the default provider, and a security manager is installed, the checkWrite method is invoked to check write access when creating the directory.createSymbolicLinkpublic static Path createSymbolicLink(Path link, Path target, FileAttribute... attrs) throws IOExceptionCreates a symbolic link to a target (optional operation). The target parameter is the target of the link. It may be an absolute or relative path and may not exist. When the target is a relative path then file system operations on the resulting link are relative to the path of the link. The attrs parameter is optional attributes to set atomically when creating the link. Each attribute is identified by its name. If more than one attribute of the same name is included in the array then all but the last occurrence is ignored. Where symbolic links are supported, but the underlying FileStore does not support symbolic links, then this may fail with an IOException. Additionally, some operating systems may require that the Java virtual machine be started with implementation specific privileges to create symbolic links, in which case this method may throw IOException.Parameters:link - the path of the symbolic link to createtarget - the target of the symbolic linkattrs - the array of attributes to set atomically when creating the symbolic linkReturns:the path to the symbolic linkThrows:UnsupportedOperationException - if the implementation does not support symbolic links or the array contains an attribute that cannot be set atomically when creating the symbolic linkFileAlreadyExistsException - if a file with the name already exists (optional specific exception)IOException - if an I/O error occursSecurityException - In the case of the default provider, and a security manager is installed, it denies LinkPermission("symbolic") or its checkWrite method denies write access to the path of the symbolic link.createLinkpublic static Path createLink(Path link, Path existing) throws IOExceptionCreates a new link (directory entry) for an existing file (optional operation). The link parameter locates the directory entry to create. The existing parameter is the path to an existing file. This method creates a new directory entry for the file so that it can be accessed using link as the path. On some file systems this is known as creating a "hard link". Whether the file attributes are maintained for the file or for each directory entry is file system specific and therefore not specified. Typically, a file system requires that all links (directory entries) for a file be on the same file system. Furthermore, on some platforms, the Java virtual machine may require to be started with implementation specific privileges to create hard links or to create links to directories.Parameters:link - the link (directory entry) to createexisting - a path to an existing fileReturns:the path to the link (directory entry)Throws:UnsupportedOperationException - if the implementation does not support adding an existing file to a directoryFileAlreadyExistsException - if the entry could not otherwise be created because a file of that name already exists (optional specific exception)IOException - if an I/O error occursSecurityException - In the case of the default provider, and a security manager is installed, it denies LinkPermission("hard") or its checkWrite method denies write access to either the link or the existing file.deletepublic static void delete(Path path) throws IOExceptionDeletes a file. An implementation may require to examine the file to determine if the file is a directory. Consequently this method may not be atomic with respect to other file system operations. If the file is a symbolic link then the symbolic link itself, not the final target of the link, is deleted. If the file is a directory then the directory must be empty. In some implementations a directory has entries for special files or links that are created when the directory is created. In such implementations a directory is considered empty when only the special entries exist. This method can be used with the walkFileTree method to delete a directory and all entries in the directory, or an entire file-tree where required. On some operating systems it may not be possible to remove a file when it is open and in use by this Java virtual machine or other programs.Parameters:path - the path to the file to deleteThrows:NoSuchFileException - if the file does not exist (optional specific exception)DirectoryNotEmptyException - if the file is a directory and could not otherwise be deleted because the directory is not empty (optional specific exception)IOException - if an I/O error occursSecurityException - In the case of the default provider, and a security manager is installed, the SecurityManager.checkDelete(String) method is invoked to check delete access to the filedeleteIfExistspublic static boolean deleteIfExists(Path path) throws IOExceptionDeletes a file if it exists. As with the delete(Path) method, an implementation may need to examine the file to determine if the file is a directory. Consequently this method may not be atomic with respect to other file system operations. If the file is a symbolic link, then the symbolic link itself, not the final target of the link, is deleted. If the file is a directory then the directory must be empty. In some implementations a directory has entries for special files or links that are created when the directory is created. In such implementations a director

Reply all
Reply to author
Forward
0 new messages