本帖最后由 邵阳 于 2012-9-12 19:28 编辑
为什么我打不能生成加密的class文件啊
Exception in thread "main" java.io.FileNotFoundException: C:\Documents (系统找不到指定的文件。)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at cn.itcast.day2.MyClassLoader.main(MyClassLoader.java:16)
我的工作区在C:\Documents and Settings下
package cn.itcast.day2;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class MyClassLoader
{
public static void main(String[]args) throws IOException
{
String srcPath=args[0];
String destDir=args[1];
FileInputStream fis=new FileInputStream(srcPath);
String destFileName=srcPath.substring(srcPath.lastIndexOf("\\")+1);
String destPath=destDir+"\\"+destFileName;
FileOutputStream fos=new FileOutputStream(destPath);
cypher(fis,fos);
fis.close();
fos.close();
}
private static void cypher(InputStream ips,OutputStream ops) throws IOException
{
int len=0;
while((len=ips.read())!=-1)
{
ops.write(len^0xff);
}
}
}
发现个问题在C:\Documents and Settings的东西是不能进行输出和输入流的
不知是不是啊
验证如下
D:\java\zuoye\ceshi5>java MyTest C:\Documents and Settings\123.png
Exception in thread "main" java.io.FileNotFoundException: C:\Documents (系统找不
到指定的文件。)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:120)
at java.io.FileInputStream.<init>(FileInputStream.java:79)
at MyTest.main(ceshi.java:77)
D:\java\zuoye\ceshi5>java MyTest c:\123.png
D:\java\zuoye\ceshi5>
|
|