【问题标题】:can i make my app (open with) windows menu with java (need examples)我可以用java制作我的应用程序(打开方式)windows菜单吗(需要示例)
【发布时间】:2016-12-06 22:04:47
【问题描述】:

我需要一些示例来使我的应用程序成为 java 中的默认文本编辑器 (我的意思是当我打开文本文件时,我的程序会打开)

我怎样才能用 Java 做到这一点??

【问题讨论】:

标签: java windows operating-system open-with


【解决方案1】:

经过多次测试,我终于找到了答案

 public static void main(String[] args) {
            FileReader file_reader = null;
        try {
            new Notepad().setVisible(true);
            file_reader = new FileReader(args[0]);
            BufferedReader br = new BufferedReader(file_reader);
            String temp = "";
            while (br.ready())
            {
                int c = br.read();
                temp = temp+ (char)c;
            }
            myarea.setText(temp);
            br.close();
            file_reader.close();
            textContent = myarea.getText();
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Notepad.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Notepad.class.getName()).log(Level.SEVERE, null, ex);
        } finally {

        }
}

你必须让你的应用程序 exe

【讨论】:

    猜你喜欢
    • 2010-09-07
    • 2016-09-15
    • 2013-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-26
    • 1970-01-01
    • 2013-08-18
    相关资源
    最近更新 更多