
Is it possible to create a desktop application to lock or encrypt file or folder in windows by using java code?? if possible can provide some reference?? because i can't find it...
thanks.

Here is an example of file locking.
import java.io.*;
import java.nio.channels.*;
public class FileLockExample {
public static void main(String[] args) throws Exception {
try {
RandomAccessFile file = new RandomAccessFile("C:/file.txt", "rw");
FileChannel fileChannel = file.getChannel();
FileLock fileLock = fileChannel.tryLock();
if (fileLock != null) {
System.out.println("File is locked");
accessFile();
}
} catch (Exception e) {
}
}
public static void accessFile() {
try {
String line = "";
BufferedReader br = new BufferedReader(
new FileReader("C:/file.txt"));
while ((line = br.readLine()) != null) {
System.out.println(line);
}
} catch (Exception e) {
System.out.println(e);
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.