public Boolean uploadFiles(File files, String filenames, String newfilenames,String url)
throws IOException {
String root =
""
boolean t = true
root = ServletActionContext
.getServletContext()
.getRealPath(
"/systemfile/picture")
try{
FileOutputStream fos = new FileOutputStream(root+
"/"+newfilenames)
FileInputStream fis = new FileInputStream(files)
byte[] buffer = new byte[
1024]
int len =
0
while ((len = fis
.read(buffer)) >
0) {
fos
.write(buffer,
0, len)
}
fis
.close()
fos
.close()
ImageChange r = new ImageChange()
String xx = newfilenames
.substring(newfilenames
.lastIndexOf(
"."), newfilenames
.length())
if(ImageUtil
.isImage(new File(root +
"/"+ newfilenames))){
if(xx
.indexOf(
"gif")>-
1||xx
.indexOf(
"GIF")>-
1){
FileOutputStream fos1 = new FileOutputStream(root+
"1/"+newfilenames)
FileOutputStream fos2 = new FileOutputStream(root+
"2/"+newfilenames)
FileInputStream fis1 = new FileInputStream(files)
FileInputStream fis2 = new FileInputStream(files)
int len1 =
0
while ((len1 = fis1
.read(buffer)) >
0 && (len2 = fis2
.read(buffer)) >
0) {
fos1
.write(buffer,
0, len1)
fos2
.write(buffer,
0, len2)
}
fis1
.close()
fis2
.close()
fos1
.close()
fos2
.close()
} else {
int width = Integer
.valueOf(MyProperties
.getByKey(
"width"))
int width2 = Integer
.valueOf(MyProperties
.getByKey(
"width2"))
BufferedImage f = r
.getBufferedImage(root +
"/"+ newfilenames)
url=root +
"/"+ newfilenames
r
.writeHighQuality(r
.zoomImage(f, width), root +
"1/", newfilenames)
r
.writeHighQuality(r
.zoomImage(f, width2), root +
"2/", newfilenames)
f
.flush()
}
}
} catch (Exception ex) {
System
.out.println(
"error:"+ex)
t = false
}
return t
}