Package com. yl. util;
Import java. Io. bufferedinputstream;
Import java. Io. bufferedoutputstream;
Import java. Io. file;
Import java. Io. fileinputstream;
Import java. Io. filenotfoundexception;
Import java. Io. fileoutputstream;
Import java. Io. ioexception;
Public class uploadfile {
Private Static string Path = "F: // upload //";
Private Final Static int buffersize = 1024*16;
Static bufferedinputstream fin;
Static bufferedoutputstream fout;
Public static Boolean uploadfile (File file, string filename ){
Boolean flag = true;
Try {
Fin = new bufferedinputstream (New fileinputstream (file), buffersize );
System. Out. println (path + filename );
Fout = new bufferedoutputstream (New fileoutputstream (path + filename), buffersize );
Byte [] buff = new byte [buffersize];
Int Len = 0;
While (LEN = fin. Read (buff)> 0 ){
Fout. Write (buff, 0, Len );
}
} Catch (filenotfoundexception e ){
Flag = false;
} Catch (ioexception e ){
Flag = false;
} Finally {
If (Fin! = NULL)
Try {
Fin. Close ();
} Catch (ioexception e ){
Flag = false;
}
If (fout! = NULL ){
Try {
Fout. Close ();
} Catch (ioexception e ){
Flag = false;
}
}
}
Return flag;
}
Public static Boolean check (string type ){
String [] STR = {"image/BMP", "image/PNG", "image/GIF", "image/jpg "};
For (Object OBJ: Str ){
If (obj. Equals (type )){
Return true;
}
}
Return false;
}
}