易截截图软件、单文件、免安装、纯绿色、仅160KB

java获取当前路径

java获取当前路径
 
1、利用System.getProperty()函数获取当前路径:
System.out.println(System.getProperty("user.dir"));//user.dir指定了当前的路径
2、使用File提供的函数获取当前路径:
File directory = new File("");//设定为当前文件夹
try{
    System.out.println(directory.getCanonicalPath());//获取标准的路径
    System.out.println(directory.getAbsolutePath());//获取绝对路径
}catch(Exceptin e){}
File.getCanonicalPath()和File.getAbsolutePath()大约只是对于new File(".")和new File("..")两种路径有所区别。
# 对于getCanonicalPath()函数,“."就表示当前的文件夹,而”..“则表示当前文件夹的上一级文件夹
# 对于getAbsolutePath()函数,则不管”.”、“..”,返回当前的路径加上你在new File()时设定的路径
# 至于getPath()函数,得到的只是你在new File()时设定的路径
比如当前的路径为 C:\test :
File directory = new File("abc");
directory.getCanonicalPath(); //得到的是C:\test\abc
directory.getAbsolutePath();    //得到的是C:\test\abc
direcotry.getPath();                    //得到的是abc
File directory = new File(".");
directory.getCanonicalPath(); //得到的是C:\test
directory.getAbsolutePath();    //得到的是C:\test\.
direcotry.getPath();                    //得到的是.
File directory = new File("..");
directory.getCanonicalPath(); //得到的是C:\
directory.getAbsolutePath();    //得到的是C:\test\..
direcotry.getPath();                    //得到的是..
另外:System.getProperty()中的字符串参数如下:
System.getProperty()参数大全
# java.version                                Java Runtime Environment version
# java.vendor    &nbs


相关文档:

将数据传给JAVA处理.

FLEX:
 
    [Bindable] public var ary1:Array=[];
   private function init():void{
                     ary1.push('黄晓华');
       ......

VB与JAVA交互


Private Sub Command1_Click()
Dim dso As New XMLDSOControl
Dim doc As IXMLDOMDocument
  Set doc = dso.XMLDocument
Dim rel  As IXMLDOMNodeList
Set x = CreateObject("Microsoft.XMLHTTP")
  x.Open "GET", "http://127.0.0.1:8080/emrb/Mrbmodel?action=dis&u ......

在Java中操作串口实现短信收发

采用串口操作进行短信收发,是比较常见的一种方式.比如,很多群发软件,用的就是这种方法.
1.配置comm.jar.
Comm.jar是Sub实现底层串口操作的API,调用了本地的DLL文件,因为Java本身不具备直接访问硬件设置的能力,都是通过调用本地方法来实现的.可以Java的官方网站下载.下载之后把其中Comm.jar包导入到工程的Classpath中,把另 ......

Flex+Java连接SQLServer数据库

首先,做一点说明。Flex是不能直接连接数据库的,这一点大家需要知道,它只能间接地连接数据库。Flex中提供了三种方式:HttpService,WebService 和RemoteObject。其中HttpService可以直接获取XML中的数据,还可以通过JSP,ASP以及PHP读取数据库中的数据,这个比较简单,而且网上也有很多例子,我就不多说了。WebService我不 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号