Code example for File

Methods: delete, getCanonicalPath, getName

0
	public void encrypt(String key, File f) {
		try { 
		//	String key = "squirrel123"; // needs to be at least 8 characters for DES 
			//File f = new File("."); 
			 
			String EncryptedFileName = f.getName() + ".encrypted";
			String DecryptedFileName = f.getName() + ".decrypted";
			File outputFile = new File(f.getCanonicalPath() + ".encrypted");
			FileInputStream fis = new FileInputStream(f);
			FileOutputStream fos = new FileOutputStream(outputFile);
			encrypt(key, fis, fos);
			f.delete();
			outputFile.renameTo(f);
		} catch (Throwable e) {
			e.printStackTrace();
		} 
	} 
	public File decrypt(String key, File f) {
		 
		try { 
			File outputFile = new File(f.getCanonicalPath() + ".decrypted");