public class T1109 { public static void main(String args[]){ System.out.println(System.getProperty("user.dir")+"\\src\\"+T1109.class.getName().replaceAll("\\.","\\\\")); } }
thx 不过如果源代码和class不分开的话 就没有src目录 有没有更直接的办法得到绝对路径呢?
/** * */ import java.io.*; import java.util.*;/** * @author Administrator * */ public class FileTest { /** * @param args */ public static void main(String[] args) { // TODO 自动生成方法存根 if (args.length == 0) args = new String[] { "." };
try { File pathName = new File(args[0]); String[] fileName = pathName.list(); for (int i = 0; i < fileName.length; i++) { File f = new File(pathName.getPath(), fileName[i]);
public static void main(String args[]){
System.out.println(System.getProperty("user.dir")+"\\src\\"+T1109.class.getName().replaceAll("\\.","\\\\"));
}
}
不过如果源代码和class不分开的话
就没有src目录
有没有更直接的办法得到绝对路径呢?
*
*/
import java.io.*;
import java.util.*;/**
* @author Administrator
*
*/
public class FileTest
{ /**
* @param args
*/
public static void main(String[] args)
{
// TODO 自动生成方法存根
if (args.length == 0)
args = new String[] { "." };
try
{
File pathName = new File(args[0]);
String[] fileName = pathName.list();
for (int i = 0; i < fileName.length; i++)
{
File f = new File(pathName.getPath(), fileName[i]);
System.out.println(fileName[i].toString());
if(f.isDirectory())
main(new String[] {f.getPath()});
}
}
catch (Exception e)
{
e.printStackTrace();
} }}
====CSDN 小助手 V2.0 2005年10月16日发布====
CSDN小助手是一款脱离浏览器也可以访问Csdn论坛的软件
界面:http://blog.csdn.net/Qqwwee_Com/archive/2005/10/16/504620.aspx
下载:http://szlawbook.com/csdnv2/csdnv2.rar为神六喝彩,向所有科技工作者致敬!
拒绝日货。