Search

Thứ Ba, 21 tháng 1, 2014

Authorized File Writer (Java)




import java.io.FileWriter;
import java.io.IOException;

public class AuthorizedFileWriter {
  public static void main(String[] args) {
    System.setSecurityManager(new SecurityManager());
    String file = "authorized.txt";
    String fileBody = "test";
    try {
      FileWriter fileWriter = new FileWriter(file);
      fileWriter.write(fileBody);
      fileWriter.close();
      System.exit(0);
    catch (IOException ioException) {
      ioException.printStackTrace();
      System.exit(1);
    }
  }

}



0 nhận xét:

Đăng nhận xét

 
Le Van Chat