/*
Files Common method: for manipulating content
Seekablebytechannel Newbytechannel (path Path, openoption...how): Gets a connection to the specified file, how to specify how to open it.
Directorystream newdirectorystream (path Path): Opens the directory specified by path
InputStream newinputstream (path Path, openoption...how): Getting InputStream objects
OutputStream newoutputstream (path Path, openoption...how): Getting OutputStream objects
*/
public void Test7 () throws ioexception{
Seekablebytechannel Newbytechannel = Files.newbytechannel (Paths.get ("1.jpg"), Standardopenoption.read);
for (Path Path:newdirectorystream) {
SYSTEM.OUT.PRINTLN (path);
}
}
/*
Files Common methods: used to judge
Boolean exists (path path, linkoption ... opts): Determine if a file exists
Boolean isdirectory (path path, linkoption ... opts): Determine if it is a directory
Boolean isexecutable (path Path): Determining whether an executable file
Boolean Ishidden (path Path): Determining if a file is hidden
Boolean isreadable (path Path): Determining whether a file is readable
Boolean iswritable (path Path): Determining whether a file is writable
Boolean notexists (path path, linkoption ... opts): Determine if the file does not exist
public static <a extends basicfileattributes> A readattributes (Path path,class<a> type,linkoption ...) Options): Gets the properties associated with the file specified by path.
*/
public void Test6 () throws ioexception{
Path PATH = Paths.get ("E:/nio/hello7.txt");
System.out.println (files.exists (path, linkoption.nofollow_links));
/*
The Get () method provided by Paths is used to obtain the Path object:
Path Get (String A, string ... more): Used to concatenate multiple strings into paths.
Path Common methods:
Boolean EndsWith (String path): Determines whether to end with path path
Boolean startswith (String path): Determine whether to start with a path
Boolean Isabsolute (): Determining whether an absolute path
Path GetFileName (): Returns the file name associated with the calling Path object
Path GetName (int idx): The pathname of the specified index position IDX returned
int GetNameCount (): Returns the number of elements behind the path root
Path GetParent (): Returns a Path object that contains the entire route and does not contain the file path specified by the Path object
Path Getroot (): Returns the root path of the calling path object
Path Resolve (path p): Resolves a relative path to an absolute path
Path Toabsolutepath (): Returns the calling path object as an absolute path
String toString (): Returns a string representation of the calling Path object
*/
public void Test2 () {
Path PATH = Paths.get ("E:/nio/hello.txt");
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.