-2
C 드라이브에 폴더가 있고 그 안에 파일이있어 그 파일을 압축하는 그루비 스크립트를 찾고 있습니다. 어떤 하나의 PLZ SoapUI 에서이 그루비 스크립트를 사용해야 할 그 폴더를 압축하는 그루비 스크립트를 작성하는 방법을 도울 수 있습니까?soapUI에서 폴더를 압축하는 Groovy 스크립트를 작성하는 방법은 무엇입니까?
감사합니다.
Latiff.
C 드라이브에 폴더가 있고 그 안에 파일이있어 그 파일을 압축하는 그루비 스크립트를 찾고 있습니다. 어떤 하나의 PLZ SoapUI 에서이 그루비 스크립트를 사용해야 할 그 폴더를 압축하는 그루비 스크립트를 작성하는 방법을 도울 수 있습니까?soapUI에서 폴더를 압축하는 Groovy 스크립트를 작성하는 방법은 무엇입니까?
감사합니다.
Latiff.
이 (Solomon Duskis's solution에 학점)
import java.io.File
import java.io.FileInputStream
import java.io.FileOutputStream
import java.util.zip.ZipEntry
import java.util.zip.ZipOutputStream
//Your folder here
File topDir = new File('c:\\FilesToZip');
//Your zip file here
ZipOutputStream zipOutput = new ZipOutputStream(new FileOutputStream('c:\\zipfile.zip'));
int topDirLength = topDir.absolutePath.length()
topDir.eachFileRecurse
{ file ->
def relative = file.absolutePath.substring(topDirLength).replace('\\', '/')
if (file.isDirectory() && !relative.endsWith('/'))
{
relative += "/"
}
ZipEntry entry = new ZipEntry(relative)
entry.time = file.lastModified()
zipOutput.putNextEntry(entry)
if(file.isFile())
{
zipOutput << new FileInputStream(file)
}
}
zipOutput.close()
를 작동합니다