-3

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 ??

Ahmed Hatem
  • 21
  • 2
  • 5

1 Answers1

0

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

Ahmed Hatem
  • 21
  • 2
  • 5