1. javase中
//获取src路径的一种方式
String srcPath = this.getClass().getClassLoader().getResource("").getPath();//获取src路径的另一种方式
String srcPath2 = InJavaSe.class.getClassLoader().getResource("").getPath();
//获取路径的另一种方式
String srcPath3 = this.getClass().getResource("/").getPath();
//获取当前类路径<包含package路径>
String classPath = this.getClass().getResource("").getPath();
2. javaee中
this.getServletContext().getRealPath("c.txt")