码迷,mamicode.com
首页 > 其他好文 > 详细

IO-file 01 名称或路径

时间:2019-11-08 19:00:39      阅读:107      评论:0      收藏:0      [点我收藏+]

标签:space   div   返回   dem   get   rgs   file   absolute   system   

package com.bwie.io;
import java.io.File;
/**
 * 名称或路径
 * [getName:名称
 * getPath
 * getAbsolutePath:绝对路径
 * getParent:父路径,不存在空]
 * @author Allen17805272076
 *
 */
public class FileDemo3 {
 
 public static void main(String[] args) {
  String path="src/userImg.GIF";
  File src = new File(path);
  System.out.println("getName()"+src.getName());//getName()userImg.GIF
  System.out.println("getPath()"+src.getPath());/*getPath()src/userImg.GIF*/
  System.out.println("getAbsolutePath()"+src.getAbsolutePath());//getAbsolutePath()C:\web\workspace\IO-study/src/userImg.GIF
  System.out.println(src.getParent());//src  如果没有,返回null
  System.out.println(src.getParentFile());//父对象
  
 }
}
 

IO-file 01 名称或路径

标签:space   div   返回   dem   get   rgs   file   absolute   system   

原文地址:https://www.cnblogs.com/zwyzwy/p/11822304.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!