I am writing some data to a file using FileWriter and BufferedWriter. I want that while writing in the file if somebody else wants to open the file in MS Excel, it should open only in read only mode

Here is a snippet of my FileWriter and BufferedWriter

                        String str=Sinput.readLine();
                        String[] arr = str.split(";");
                            File file = new File(arr[1]+".txt");
                            FileWriter fstream = new FileWriter(file, true);
                            BufferedWriter out = new BufferedWriter(fstream);
                            dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
                            Date date = new Date();
                            for(int i=1;i<6;i++)

Currently, When I try to open the file in MS Excel it opens in normal mode and due to which my program is not able to write in file and gives an excepton. What should I do?

This question has already been answered. Start a new discussion instead.