Java 開啟檔案的兩種方式

來源:互聯網
上載者:User

標籤:

 

import java.awt.Desktop;import java.io.File;import java.io.IOException;public class LnkDemo {    public static void main(String[] args) throws IOException {        File f=new File("d://com.lnk");        System.out.println(f.exists());        System.out.println(f.isDirectory());        Runtime.getRuntime().exec("explorer /e,/select,"+f.getAbsolutePath());//        Desktop.getDesktop().open(f);    }}

 

 

摘要

本文講述explorer.exe(資源管理員)的命令列。

文法

EXPLORER.EXE [/n][/e][,/root,<object>][[,/select],<sub object>]

/n: 預設選項,用我的電腦視圖為每個選中的item開啟一個單獨的視窗,  即使該視窗已經被開啟。

/e: 使用資源管理員視圖。資源管理員視圖和Windows 3.x的檔案管理工具非常相似。

/root,<object>: 指定視圖目錄根,預設使用案頭作為根目錄。

/select,<sub object>: 選中指定對象。如果使用"/select" , 則父目錄被開啟,並選中指定對象

例子

開啟資源管理員視圖並以C:\Windows為目錄根瀏覽

explorer /e,/root,C:\Windows

開啟資源管理員視圖並選中Calc.exe

explorer /e,/select,c:\windows\system32\calc.exe

注意:/root和/select最好不要同時使用。

http://www.cnblogs.com/ymind/archive/2012/03/30/explorer-command-args.html

 

Java 開啟檔案的兩種方式

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.