本帖最后由 傅宇 于 2013-4-9 21:32 编辑
- class MyClassLoader{
- public static void main(String[] args){
- String srcPath = args[0];
- String destDir = args[1];
- //反向索引+1
- String destName = srcPath.substring(srcPath.lastIndexOf('\\')+1);
- String destPath = destDir+"\\"+destName;
- FileInputStream fis = new FileInputStream(srcPath);
- FileOutputStream fos = new FileOutputStream(destPath);
- cypher(fis,fos);
- fis.close();
- fos.close();
- }
-
- //加密函数
- private static void cypher(FileInputStream fis,FileOutputStream fos){
- int a = 0;
- while((a=fis.read()) != -1){
- //通过异或
- fos.write(a^0xff);
- }
- }
- }
- //对这个文件进行加密
- class ClassLoaderAttachment extends Date{
- public String toString(){
- return "hello 123";
- }
- }
- class ClassLoaderTest{
- public static void main(String[] args){
- System.out.println(new ClassLoderAttachment().toString());
- }
- }
复制代码 为什么ClassLoaderAttachment要继承Date? |