title: I cant make the text file as read only mode in java
body: <pre><code>package com.studytrails.tutorials.springremotingrmiserver;
  
  import java.lang.Object;
  import java.awt.Desktop;
  import java.io.*;
  import org.springframework.context.ApplicationContext;
  import org.springframework.context.support.ClassPathXmlApplicationContext;
  import org.springframework.core.io.Resource;
  
  public class GreetingServiceImpl implements GreetingService 
  {
      @Override
      public String getGreeting(String name) {
          return "Hello " + name + "!";
      }
  
      public String getText() {
          ApplicationContext appContext = new ClassPathXmlApplicationContext(new String[]{"spring-config-server.xml"});
          Resource resource = appContext.getResource("file:D:\\text\\test.txt");
          StringBuilder builder = new StringBuilder();
          try {
              InputStream is = resource.getInputStream();
              BufferedReader br = new BufferedReader(new InputStreamReader(is));
              File temp=File.createTempFile("output", ".tmp");
              String filePath=temp.getAbsolutePath();
              System.out.println(""+filePath);
              String tem=temp.getName();
              String line;
              PrintWriter out = new PrintWriter(new FileWriter(tem));
              //System.out.println(""+filePath);
              while ((line = br.readLine()) != null) {
                  out.println(line);
              }
              temp.setReadOnly();
              String[] cmd = {"notepad",tem}; 
              Runtime runtime = Runtime.getRuntime();
              Process proc = runtime.exec(cmd);
              // proc.getInputStream();
              out.close();
              br.close();
              //temp.deleteOnExit();
              }
          catch(IOException e) {
              e.printStackTrace();
          }
          return builder.toString();
      }
  }
  </code></pre>
  
  <p>In above code I am not able to setReadonly(); command to temp file. File displayed with all options can you suggest how to make the temp file as not modified and even it is not able to save to another location. I need this file only displayed at run time of the program. During that time user does not change any content and it could not be save as  another location.</p>