java命令行文件管理器
这是用java写的给予命令行的文件管理器,可以在命令行实现文件的创建、删除,重命名、拷贝,打开路径、压缩解压、加密解密等功能,可以说功能的是实现比较全面。
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2013-10-16 15:32 CommandLineFileManager
文件 524 2013-10-15 17:15 CommandLineFileManager.classpath
文件 398 2013-10-10 15:39 CommandLineFileManager.project
目录 0 2013-10-10 15:39 CommandLineFileManager.settings
文件 598 2013-10-10 15:39 CommandLineFileManager.settingsorg.eclipse.jdt.core.prefs
文件 2000557 2013-07-08 20:18 CommandLineFileManagerant.jar
目录 0 2013-10-25 17:57 CommandLineFileManagerin
文件 2280 2013-10-25 17:57 CommandLineFileManagerinCopyDirectory.class
文件 1159 2013-10-25 17:57 CommandLineFileManagerinCopyFile.class
文件 1417 2013-10-25 17:57 CommandLineFileManagerinCreateFile.class
文件 1954 2013-10-25 17:57 CommandLineFileManagerinDeleteFile.class
文件 3601 2013-10-25 17:57 CommandLineFileManagerinDESencryption.class
文件 1051 2013-10-25 17:57 CommandLineFileManagerinEnterDirectory.class
文件 3340 2013-10-25 17:57 CommandLineFileManagerinFileManager.class
文件 3816 2013-10-25 17:57 CommandLineFileManagerinFileSorter.class
文件 1390 2013-10-25 17:57 CommandLineFileManagerinListDirectory.class
文件 1098 2013-10-25 17:57 CommandLineFileManagerinReName.class
文件 3122 2013-10-25 17:57 CommandLineFileManagerinSplitImageUtil.class
文件 5780 2013-10-25 17:57 CommandLineFileManagerinipUtil.class
文件 140588 2013-10-16 14:28 CommandLineFileManagerCommandLineFileManager.jpg
文件 245039 2013-10-15 17:13 CommandLineFileManagerjunit-4.11.jar
目录 0 2013-10-15 23:11 CommandLineFileManagermyfile
目录 0 2013-10-15 23:11 CommandLineFileManagermyfilefile3
文件 0 2013-10-15 23:11 CommandLineFileManagermyfilefile3456.txt
目录 0 2013-10-15 17:02 CommandLineFileManagersrc
文件 2845 2013-10-16 15:19 CommandLineFileManagersrcDESencryption.java
文件 9080 2013-10-16 00:43 CommandLineFileManagersrcFileManager.java
文件 4092 2013-10-16 00:43 CommandLineFileManagersrcFileSorter.java
文件 3158 2013-10-16 00:43 CommandLineFileManagersrcSplitImageUtil.java
文件 5841 2013-10-16 14:57 CommandLineFileManagersrcipUtil.java
import java.io.*;
import java.security.*;
import java.util.*;
import javax.crypto.*;
public class DESencryption {
Key key;
public DESencryption() {
}
public DESencryption(String str) throws NoSuchAlgorithmException {
getKey(str);// 用输入的str生成key
}
// 用输入的参数strKey和内置的DES表示的算法生成DES加密需要的的密钥
public void getKey(String strKey) throws NoSuchAlgorithmException {// 生成密钥的函数
KeyGenerator keyGenerator = KeyGenerator.getInstance(“DES“);
keyGenerator.init(new SecureRandom(strKey.getBytes()));
this.key = keyGenerator.generateKey();
keyGenerator = null;
}
/*
* 对文件oldFile加密保存到newFile中 oldFile 要加密的文件如E:/test1.txt newFile
* 加密后的文件如E:/test2.txt
*/
public void encrypt(String oldFile String newFile) throws Exception {
Cipher cipher = Cipher.getInstance(“DES“);
cipher.init(Cipher.ENCRYPT_MODE this.key);
InputStream is = new FileInputStream(oldFile);
OutputStream out = new FileOutputStream(newFile);
CipherInputStream cis = new CipherInputStream(is cipher);
byte[] buffer = new byte[1024];
int k;
while ((k = cis.read(buffer)) > 0) {
out.write(buffer 0 k);
}
cis.close();
is.close();
out.close();
}
/*
* 对newFile解密保存到decFile中 newFile是待解密的文件 decFile是解密后的文件
*/
public void decrypt(String newFile String decFile) throws Exception {
Cipher cipher = Cipher.getInstance(“DES“);
cipher.init(Cipher.DECRYPT_MODE this.key);
InputStream is = new FileInputStream(newFile);
OutputStream out = new FileOutputStream(decFile);
CipherOutputStream cos = new CipherOutputStream(out cipher);
byte[] buffer = new byte[1024];
int k;
while ((k = is.read()) >= 0) {
cos.write(buffer 0 k);
}
cos.close();
out.close();
is.close();
}
public static void DES() throws Exception {
System.out.println(“inuput encrypted password: “);
Scanner scan = new Scanner(System.in);
String encpasswordassword = scan.nextLine(); // 以上两行用来实现字符串的输入。
DESencryption desEncryption = new DESencryption(encpasswordassword);// 对称加密的密码所在
System.out.println(“encrypt: inuput source file and target file: “);
String sourcee = scan.next();
String target = scan.next();
desEncryption.encrypt(sourcee target); // 加密
System.out.println(“ encryption is complete!“);
System.out.println(“decrypt:inuput decryptioned password:“);
Scanner scanf = new Scanner(System.in);
String decPassword = scanf.nextLine();
DESencryption tdd = new DESencryption(decPassword);
System.out.println(“decrypt: inuput source file and target file: “);
String sourced = scan.next();
String targetd = scan.next();
tdd.decrypt(sourced targetd); // 解密
System.out.println(“ decryption is complete“);
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2013-10-16 15:32 CommandLineFileManager
文件 524 2013-10-15 17:15 CommandLineFileManager.classpath
文件 398 2013-10-10 15:39 CommandLineFileManager.project
目录 0 2013-10-10 15:39 CommandLineFileManager.settings
文件 598 2013-10-10 15:39 CommandLineFileManager.settingsorg.eclipse.jdt.core.prefs
文件 2000557 2013-07-08 20:18 CommandLineFileManagerant.jar
目录 0 2013-10-25 17:57 CommandLineFileManagerin
文件 2280 2013-10-25 17:57 CommandLineFileManagerinCopyDirectory.class
文件 1159 2013-10-25 17:57 CommandLineFileManagerinCopyFile.class
文件 1417 2013-10-25 17:57 CommandLineFileManagerinCreateFile.class
文件 1954 2013-10-25 17:57 CommandLineFileManagerinDeleteFile.class
文件 3601 2013-10-25 17:57 CommandLineFileManagerinDESencryption.class
文件 1051 2013-10-25 17:57 CommandLineFileManagerinEnterDirectory.class
文件 3340 2013-10-25 17:57 CommandLineFileManagerinFileManager.class
文件 3816 2013-10-25 17:57 CommandLineFileManagerinFileSorter.class
文件 1390 2013-10-25 17:57 CommandLineFileManagerinListDirectory.class
文件 1098 2013-10-25 17:57 CommandLineFileManagerinReName.class
文件 3122 2013-10-25 17:57 CommandLineFileManagerinSplitImageUtil.class
文件 5780 2013-10-25 17:57 CommandLineFileManagerinipUtil.class
文件 140588 2013-10-16 14:28 CommandLineFileManagerCommandLineFileManager.jpg
文件 245039 2013-10-15 17:13 CommandLineFileManagerjunit-4.11.jar
目录 0 2013-10-15 23:11 CommandLineFileManagermyfile
目录 0 2013-10-15 23:11 CommandLineFileManagermyfilefile3
文件 0 2013-10-15 23:11 CommandLineFileManagermyfilefile3456.txt
目录 0 2013-10-15 17:02 CommandLineFileManagersrc
文件 2845 2013-10-16 15:19 CommandLineFileManagersrcDESencryption.java
文件 9080 2013-10-16 00:43 CommandLineFileManagersrcFileManager.java
文件 4092 2013-10-16 00:43 CommandLineFileManagersrcFileSorter.java
文件 3158 2013-10-16 00:43 CommandLineFileManagersrcSplitImageUtil.java
文件 5841 2013-10-16 14:57 CommandLineFileManagersrcipUtil.java
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)