javawindowsoperating-systemopen-with

can i make my app (open with) windows menu with java (need examples)


i need some example to make my app as default text editor in java (i mean when I open the text file opens with my program)

How can I do that with Java ??


Solution

  • I finally found the answer after many tests When i open the text file with my app from open with menu in windows

     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 {
    
            }
    }
    

    you must make your app exe