设为首页 加入收藏

TOP

java中获得文件的物理路径
2014-11-23 22:12:31 】 浏览:420
Tags:java 获得 文件 物理 路径

  package com.bd.test;


  import java.io.File;


  import java.io.IOException;


  import java.net.URL;


  public class csDao {


  public static void main(String[] args)


  {


  csDao getclasspath = new csDao();


  System.out.println(getclasspath.getClassPath());


  File file = new File("index.html");


  try {


  System.out.println("获得webroot下文件的路径"+file.getCanonicalPath());


  } catch (IOException e) {


  // TODO Auto-generated catch block


  e.printStackTrace();


  }


  }


  /**


  *在类中取得当前文件所在的相对路径与绝对路径


  *


  * @return String


  */


  public String getClassPath()


  {


  String strClassName = getClass().getName();


  String strPackageName = "";


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇java查看JDK中底层源码 下一篇Java中classpath和路径的使用

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目