I cant place inside code

import java.io.*;
import java.util.jar.*;
import java.util.*;

public class Main
{
	private static void unzipping(File file,File dir) throws Exception
	{
		JarFile jar=new JarFile(file);

		for(Enumeration entries=jar.entries();entries.hasMoreElements();){
			JarEntry je=(JarEntry)entries.nextElement();
			File unzippingf=new File(dir,je.getName());
			if(je.isDirectory()&&!unzippingf.exists()){
				unzippingf.mkdirs();
				continue;
			}
			else if(!unzippingf.getParentFile().exists()){
				unzippingf.getParentFile().mkdirs();
				FileOutputStream fos=new FileOutputStream(unzippingf);
				InputStream is=jar.getInputStream(je);
				byte[] buffer=new byte[4096];
				int count;
				while((count=is.read(buffer,0,buffer.length))!=1){
					fos.write(buffer,0,buffer.length);
					fos.close();
				}
			}
		}
	}
	public static void main(String[] args)throws Exception
	{
	File f=new File("/mnt/sdcard/test.jar");
	File d=new File("/mnt/sdcard/l/");
	unzipping(f,d);
	}
}

---------------------------------------------

Exc
java.io.IOException: write failed: EBADF (Bad file number)
	at libcore.io.IoBridge.write(IoBridge.java:462)
	at java.io.FileOutputStream.write(FileOutputStream.java:187)
	at Main.unzipping(Main.java:25)
	at Main.main(Main.java:35)
	at java.lang.reflect.Method.invokeNative(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:511)
	at com.aide.ui.build.java.RunJavaActivity$3.run(SourceFile:293)
	at java.lang.Thread.run(Thread.java:856)
Caused by: libcore.io.ErrnoException: write failed: EBADF (Bad file number)
	at libcore.io.Posix.writeBytes(Native Method)
	at libcore.io.Posix.write(Posix.java:178)
	at libcore.io.BlockGuardOs.write(BlockGuardOs.java:191)
	at libcore.io.IoBridge.write(IoBridge.java:457)
	... 7 more