java absolute_Java Path isAbsolute()用法及代码示例

Java Path接口已添加到Java 7中的Java NIO。Java.nio.file.Path的isAbsolute()方法用于检查此路径是否为绝对路径。当且仅当此路径是绝对路径时,此方法才返回true。绝对路径是无需与其他路径信息结合即可找到文件的路径。

用法:

boolean isAbsolute()

参数:此方法不接受任何内容。

返回值:仅当此路径是绝对路径时,此方法才返回true。

以下示例程序旨在说明isAbsolute()方法:

示例1:

// Java program to demonstrate

// java.nio.file.Path.isAbsolute() method

import java.io.IOException;

import java.nio.file.Path;

import java.nio.file.Paths;

public class GFG {

public static void main(String[] args)

throws IOException

{

// create an object of Path

Path path

= Paths.get("D:\\eclipse\\configuration"

+ "\\org.eclipse.update");

// call isAbsolute() to get check

// path is absolute or not

boolean isAbsolute = path.isAbsolute();

// print isAbsolute

System.out.println("Path is Absolute: "

+ isAbsolute);

}

}

输出:

cfba7049950705b917420865619c7ac2.png

示例2:

// Java program to demonstrate

// java.nio.file.Path.isAbsolute() method

import java.io.IOException;

import java.nio.file.Path;

import java.nio.file.Paths;

public class GFG {

public static void main(String[] args)

throws IOException

{

// create object of Path

Path path = Paths.get("temp\\Spring");

// call isAbsolute() to get check

// path is absolute or not

boolean isAbsolute = path.isAbsolute();

// print isAbsolute

System.out.println("Path is Absolute: "

+ isAbsolute);

}

}

输出:

19e036e5422842cd79780dfbd8942335.png

For courses in computer programming and engineering. Beginner to Intermediate Programming in Java Absolute Java provides a comprehensive reference to programming in the Java language. Accessible to both beginner and intermediate programmers, the text focuses around specifically using the Java language to practice programming techniques. The Sixth Edition is extremely flexible and easily applicable to a wide range of users. Standalone and optional chapters allow instructors to adapt the text to a variety of curse content. Highly up-to-date with new content and information regarding the use of Java, this text introduces readers to the world of programming through a widely used and relevant language. Also Available with MyProgrammingLab ™ This title is also available with MyProgrammingLab – an online homework, tutorial, and assessment program designed to work with this text to engage students and improve results. Within its structured environment, students practice what they learn, test their understanding, and pursue a personalized study plan that helps them better absorb course material and understand difficult concepts. Students, if interested in purchasing this title with MyProgrammingLab, ask your instructor for the correct package ISBN and Course ID. Instructors, contact your Pearson representative for more information. Interactive Practice helps students gain first-hand programming experience in an interactive online environment. Step-by-step VideoNote Tutorials enhance the programming concepts presented in your Pearson textbook by allowing students to view the entire problem-solving process outside of the classroom–when they need help the most. Pearson eText gives students access to their textbook anytime, anywhere. In addition to note taking, highlighting, and bookmarking, the Pearson eText offers interactive and sharing features. Rich media options let students watch lecture and example videos as they read or do their homework. Instructors can share their comments or highlights, and students can add their own, creating a tight community of learners in your class. The Pearson eText companion app allows existing subscribers to access their titles on an iPad or Android tablet for either online or offline viewing. Dynamic grading and assessment ensure your students’ submissions are automatically graded, both saving you time, and offering students immediate learning opportunities. Gradebook results can be exported to Excel to use with your LMS.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值