如何锁定或提供密码给文件 [英] How to lock or give password to file
本文介绍了如何锁定或提供密码给文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
import java.io.*;
public class CreateFile1{
public static void main(String[] args) throws IOException{
File f;
f=new File("myfile.txt");
if(!f.exists()){
f.createNewFile();
System.out.println("New file \"myfile.txt\" has been created
to the current directory");
}
}
}
我们可以用密码锁定此文件吗?这样,当任何人在程序中或手动打开此文件时,都应要求输入密码.
Can we lock this file with password. So that when anyone open this file in program or manually it should ask for password.
推荐答案
您不能.当然不是Java.为此,需要外壳程序扩展才能在终端计算机上运行.您最能做的就是将其放在受密码保护的zip中.
You can''t. Certainly not in Java. To do this requires a shell extension to run on the end machine. The closest you can do, is to put it in a password protected zip.
这篇关于如何锁定或提供密码给文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文