Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

File handling

807588Jul 13 2009 — edited Jul 13 2009
Here is the java program i've written to create a folder ,write files into folder and zip the folder...its throwing a filenot found exception.kindly help in finding the mistake ive done:

public static void main(String args[])
{
String fileList[] = {"D:/SwingsEx/TestingZip/C0187000.SDI","D:/SwingsEx/TestingZip/C0187000.SFH","D:/SwingsEx/TestingZip/C0187000.SAI","D:/SwingsEx/TestingZip/C0187000.SEI"};
byte arrByt[] = new byte[1024];
String strZip = "D:/SwingsEx/TestingZip/Testing.zip";
try
{
//ZipOutputStream out = new ZipOutputStream(new FileOutputStream(strZip));
for (int i=0; i<fileList.length; i++)
{

File f;
File fDir = new File("D:\\SwingsEx\\TestingZip");
fDir.mkdirs();
f=new File(fDir,fileList);
// String files[]=fDir.list();
FileInputStream fis=new FileInputStream(f);

BufferedInputStream inr= null;
FileOutputStream fout=new FileOutputStream(f.getPath());
BufferedOutputStream out=new BufferedOutputStream(fout);
//ByteArrayOutputStream baOut = new ByteArrayOutputStream();
byte [] fileData = null;
int readCount=0;
System.out.println("fName---0000077777");
inr = new BufferedInputStream(fis);
System.out.println("fName---00000");
while ((readCount = inr.read()) > -1)
{
out.write(readCount);
System.out.println("fName---9999999");
}
System.out.println("fName--8888888-");
out.flush();
System.out.println("fName--77777-");
//fileData = baOut.toByteArray();
System.out.println("fName--66666-");
//baOut.close();
fis.close();
fout.close();
inr.close();
out.close();
//System.out.println("fileData----"+fileData);
System.out.println("Zip file created successfully");
}


}
catch (FileNotFoundException e)
{e.printStackTrace();}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 10 2009
Added on Jul 13 2009
6 comments
174 views