急,求高人指点,高分悬赏!!!我给压缩程序写的界面,点按钮后,eclipse提示java.io.FileNotFoundExcept

好像文件导入不进去,不知哪出错,怎么修改!
部分界面代码:
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == btn3) {
liulan1.setMultiSelectionEnabled(true);
int m = liulan1.showOpenDialog(null);

if (m == JFileChooser.APPROVE_OPTION) {
File sourceDIR=liulan1.getSelectedFile();
importf.setText(sourceDIR.getAbsolutePath());
}
}

if (arg0.getSource() == btn4){
liulan2.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

liulan2.setMultiSelectionEnabled(true);
int n = liulan2.showOpenDialog(null);

if (n == JFileChooser.APPROVE_OPTION) {
File targetZipFile =liulan2.getSelectedFile();
exportf.setText(targetZipFile.getAbsolutePath());
}
}

if (arg0.getSource()==btn1){

String save1="";
String save2="";

if(sourceDIR!=null){
save1=sourceDIR.getAbsolutePath()+"/"+sourceDIR.getName();
save2=targetZipFile.getAbsolutePath()+"/"+sourceDIR.getName()+".zip";
}

new gzip(save1,save2);
}

if (arg0.getSource()==btn2){
String save1="";
String save2="";

if(sourceDIR!=null){
save1=sourceDIR.getAbsolutePath()+"/"+sourceDIR.getName().replaceAll("zip","");
save2=targetZipFile.getAbsolutePath()+"/"+sourceDIR.getName();
}
//if(targetZipFile.getName().lastIndexOf("zip")>0){

new ungzip(save1,save2);
//}
}
}

调用的主程序代码:
package 主类;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.GZIPOutputStream;

public class gzip
{
public gzip(String save1,String save2){
if(save1.length()+save1.length()!= 2)
{
System.out.println("Usage:java gzip ");

}

try
{
int num;
FileInputStream fin = new FileInputStream(save1);

FileOutputStream fout = new FileOutputStream(save1);

GZIPOutputStream gzout = new GZIPOutputStream(fout);
byte[] buf = new byte[1024];

while ((num = fin.read(buf)) != -1)
{
gzout.write(buf, 0, num);
}
gzout.close();
fout.close();
fin.close();
}
catch (IOException e) {
System.out.println(e);
}
}
}
单独这样是可以运行的,但我放界面,改了参数,导文件进去,就没反应了
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.GZIPOutputStream;

public class gzip
{
public gzip(String args[]){
if(args.length!= 2)
{
System.out.println("Usage:java gzip ");

}

try
{
int num;
FileInputStream fin = new FileInputStream(args[0]);

FileOutputStream fout = new FileOutputStream(args[0]);

GZIPOutputStream gzout = new GZIPOutputStream(fout);
byte[] buf = new byte[1024];

while ((num = fin.read(buf)) != -1)
{
gzout.write(buf, 0, num);
}
gzout.close();
fout.close();
fin.close();
}
catch (IOException e) {
System.out.println(e);
}
}
}

应该是细节上出的错,代码,我看了,也没什么错!你在仔细看看
温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-04-30
FileInputStream fin = new FileInputStream(save1);
save1 变量的路径文件不存在,实在是看不懂你的写的代码,几个按钮只命名为 btn1 btn2 btn3 ....到底什么功能都不知道,怎么帮你分析问题呢?
相似回答
大家正在搜