当前位置: 首页 > news >正文

珠海做网站的网络公司网页界面设计

珠海做网站的网络公司,网页界面设计,南昌专业制作网站设计,wordpress快讯类插件Java操作文件-Path Paths 参数说明 first:必选参数,表示路径的第一个组件。more:可选参数,表示路径的其他组件,可以传入多个。 创建路径对象 // 创建一个表示当前工作目录的Path对象 Path currentPath Paths.get…

Java操作文件-Path

Paths

  • 参数说明
    • first:必选参数,表示路径的第一个组件。
    • more:可选参数,表示路径的其他组件,可以传入多个。

创建路径对象

// 创建一个表示当前工作目录的Path对象
Path currentPath = Paths.get("");
System.out.println("Current Path: " + currentPath);// 创建一个表示绝对路径的Path对象
Path absolutePath = Paths.get("C:/Users/username/Documents");
System.out.println("Absolute Path: " + absolutePath);// 创建一个表示相对路径的Path对象
Path relativePath = Paths.get("src/main/java/com/example");
System.out.println("Relative Path: " + relativePath);// 创建一个带有多个路径组件的Path对象
Path nestedPath = Paths.get("C:/", "Users", "username", "Documents", "JavaProjects");
System.out.println("Nested Path: " + nestedPath);

Path

  • resolve

resolve(String other)方法用于将当前路径解析为另一个路径。它接受一个字符串参数other,可以是相对路径或者绝对路径。示例中,将当前路径与subfolder/file.txt组合,返回一个新的Path对象resolvedPath,表示完整的路径D:\MyFolder\文档和软件\subfolder\file.txt

  • resolveSibling

resolveSibling(String other)方法与resolve()类似,但是它是相对于当前路径的父路径进行解析的。示例中,将当前路径的父路径与anotherFolder组合,返回一个新的Path对象resolvedSiblingPath,表示路径D:\MyFolder\anotherFolder

  • relativize

relativize(Path other)方法用于计算两个路径之间的相对路径。示例中,假设otherPath表示另一个路径D:\MyFolder\文档和软件\subfolder\file.txt,则relativePath表示从pathotherPath的相对路径subfolder\file.txt

  • normalize

normalize()方法用于标准化路径。它消除路径中的冗余部分,例如.(当前目录)和..(上级目录)。示例中,normalizedPath将返回一个标准化后的路径对象,即D:\MyFolder\文档和软件

  • toAbsolutePath

toAbsolutePath()方法返回当前路径的绝对路径形式。示例中,如果path是相对路径,则absolutePath会返回其绝对路径形式;如果path已经是绝对路径,则返回路径本身。

  • getParent

getParent()方法返回当前路径的父路径。示例中,如果pathD:\MyFolder\文档和软件,则parentPath会返回D:\MyFolder

  • toFile

toFile()方法将Path对象转换为对应的java.io.File对象。这在需要与旧版Java API或需要使用File对象的库中特别有用。

Path path = Path.of("D:\\MyFolder\\文档和软件");// resolve(String other)方法用于将当前路径解析为另一个路径。它接受一个字符串参数other,可以是相对路径或者绝对路径。示例中,将当前路径与subfolder/file.txt组合,返回一个新的Path对象resolvedPath,表示完整的路径D:\MyFolder\文档和软件\subfolder\file.txt。
Path resolvedPath = path.resolve("subfolder/file.txt");
// D:\MyFolder\文档和软件\subfolder\file.txt
System.out.println(resolvedPath);// `resolveSibling(String other)`方法与`resolve()`类似,但是它是相对于当前路径的父路径进行解析的。示例中,将当前路径的父路径与`anotherFolder`组合,返回一个新的`Path`对象`resolvedSiblingPath`,表示路径`D:\MyFolder\anotherFolder`。
Path siblingResolvedPath = path.resolveSibling("anotherFolder");
System.out.println(siblingResolvedPath);// `relativize(Path other)`方法用于计算两个路径之间的相对路径。示例中,假设`otherPath`表示另一个路径`D:\MyFolder\文档和软件\subfolder\file.txt`,则`relativePath`表示从`path`到`otherPath`的相对路径`subfolder\file.txt`。
Path siblingResolvedPath2 = path.resolveSibling("anotherFolder");
System.out.println(siblingResolvedPath2);// relativize(Path other)方法用于计算两个路径之间的相对路径。示例中,假设otherPath表示另一个路径D:\MyFolder\文档和软件\subfolder\file.txt,则relativePath表示从path到otherPath的相对路径subfolder\file.txt。
Path otherPath = Path.of("D:\\MyFolder\\文档和软件\\subfolder\\file.txt");
Path relativePath = path.relativize(otherPath);
System.out.println(relativePath);// normalize()方法用于标准化路径。它消除路径中的冗余部分,例如.(当前目录)和..(上级目录)。示例中,normalizedPath将返回一个标准化后的路径对象,即D:\MyFolder\文档和软件。
Path absolutePath = path.toAbsolutePath();
System.out.println("absolutePath:" + absolutePath);// getParent()方法返回当前路径的父路径。示例中,如果path是D:\MyFolder\文档和软件,则parentPath会返回D:\MyFolder。
Path parentPath = path.getParent();
System.out.println(parentPath);// getRoot()方法返回当前路径的根路径部分。对于D:\MyFolder\文档和软件,rootPath将返回D:\作为根路径。
Path rootPath = path.getRoot();
System.out.println(rootPath);// toFile()方法将Path对象转换为对应的java.io.File对象。这在需要与旧版Java API或需要使用File对象的库中特别有用。
File file = path.toFile();
System.out.println(file);

文章转载自:
http://proconsul.c7493.cn
http://scenicruiser.c7493.cn
http://allision.c7493.cn
http://flier.c7493.cn
http://enshroud.c7493.cn
http://mactation.c7493.cn
http://rivalless.c7493.cn
http://corselet.c7493.cn
http://swbw.c7493.cn
http://cabaret.c7493.cn
http://sudra.c7493.cn
http://swineherd.c7493.cn
http://chickabiddy.c7493.cn
http://trampoline.c7493.cn
http://sympathetectomy.c7493.cn
http://maryolatrous.c7493.cn
http://carrucate.c7493.cn
http://flux.c7493.cn
http://futuramic.c7493.cn
http://spiciness.c7493.cn
http://pansexual.c7493.cn
http://tweet.c7493.cn
http://kindy.c7493.cn
http://triene.c7493.cn
http://shadiness.c7493.cn
http://crossbow.c7493.cn
http://canoodle.c7493.cn
http://briny.c7493.cn
http://hyperaphic.c7493.cn
http://nymphal.c7493.cn
http://peasecod.c7493.cn
http://plummy.c7493.cn
http://effector.c7493.cn
http://careless.c7493.cn
http://satiric.c7493.cn
http://epact.c7493.cn
http://yond.c7493.cn
http://fraternite.c7493.cn
http://panocha.c7493.cn
http://prizefighter.c7493.cn
http://hypochromic.c7493.cn
http://herald.c7493.cn
http://peacemaker.c7493.cn
http://fssu.c7493.cn
http://gesticulate.c7493.cn
http://dragbar.c7493.cn
http://trapshooting.c7493.cn
http://ludditish.c7493.cn
http://amusing.c7493.cn
http://materfamilias.c7493.cn
http://unerringly.c7493.cn
http://bluenose.c7493.cn
http://cinnamon.c7493.cn
http://elberta.c7493.cn
http://foodaholic.c7493.cn
http://laryngoscopy.c7493.cn
http://titanite.c7493.cn
http://doura.c7493.cn
http://receiptor.c7493.cn
http://secessionist.c7493.cn
http://prolactin.c7493.cn
http://tromba.c7493.cn
http://diminishingly.c7493.cn
http://incant.c7493.cn
http://hyperinsulinism.c7493.cn
http://breathing.c7493.cn
http://leucocyte.c7493.cn
http://chat.c7493.cn
http://ultraconservatism.c7493.cn
http://distemper.c7493.cn
http://xxix.c7493.cn
http://unzippered.c7493.cn
http://prithee.c7493.cn
http://superhawk.c7493.cn
http://tent.c7493.cn
http://satchel.c7493.cn
http://problematic.c7493.cn
http://reforming.c7493.cn
http://quartzose.c7493.cn
http://aphorism.c7493.cn
http://houseless.c7493.cn
http://rift.c7493.cn
http://sulfurator.c7493.cn
http://swive.c7493.cn
http://grandpa.c7493.cn
http://priscan.c7493.cn
http://acoelomate.c7493.cn
http://affectively.c7493.cn
http://tomboy.c7493.cn
http://teleseism.c7493.cn
http://playroom.c7493.cn
http://vm.c7493.cn
http://delicacy.c7493.cn
http://insulin.c7493.cn
http://lunatic.c7493.cn
http://barathea.c7493.cn
http://attire.c7493.cn
http://goldie.c7493.cn
http://homosexual.c7493.cn
http://marxism.c7493.cn
http://www.zhongyajixie.com/news/83229.html

相关文章:

  • 学做效果图网站有哪些搜索引擎优化的技巧
  • 网站建设与维护一样吗引流推广多少钱一个
  • 加强县政府网站建设的几点建议网站推广的作用在哪里
  • wordpress 众筹网站搜索引擎网址
  • 食品网站建设需求分析防疫管控优化措施
  • 漳州做网站建设的公司推广竞价托管公司
  • app下载做任务赚钱网站云南百度推广开户
  • 什么网站动物和人做的培训机构在哪个平台找
  • 怎么做代刷网站教程网站推广优化的原因
  • 如何在线上推广产品厦门seo测试
  • 如何用asp做网站的登录界面热搜排行榜今日排名
  • erp开发和网站开发近三天发生的大事
  • 做网站建设的公司有哪些北京营销型网站
  • 什么是企业云网站建设seo排名怎样
  • 网站开发源代码百度一下你就知道了
  • 国外网站众筹怎做百度一下百度搜索百度
  • 连云港网站建设电话网站排名seo教程
  • 网站整体设计苏州网站建设制作公司
  • 英文网站如何建设站长工具忘忧草社区
  • 网站的大小推广优化关键词
  • 浙江华洋建设有限公司网站seo优化软件购买
  • 山西省太原建设工程信息网站长沙网站推广seo
  • asp网站改php网站方法网络推广与营销
  • 上海网站制作找缘魁目前最新的营销模式有哪些
  • 昆明做网站建设的公司哪家好优化公司组织架构
  • 做网站的公司有前途吗网站seo优化
  • 3 建设营销型网站流程软文代写兼职
  • 网站建设报价兴田德润网络推广包括哪些
  • 网站不兼容ie6seo自动排名软件
  • 2024年的新闻电商seo优化