finally
{
filesets = savedFileSets;
if (tOut != null)
{
try
{
// close up
tOut.close();
}
catch (IOException e)
{
//LOG.error(e);
}
}
}
}
/**
* tar a file
* @param file the file to tar
* @param tOut the output stream
* @param vPath the path name of the file to tar
* @param tarFileSet the fileset that the file came from.
* @throws IOException 抛出IO异常
*/
protected void tarFile(File file, TarOutputStream tOut, String vPath,
TarFileSet tarFileSet) throws IOException
{
FileInputStream fIn = null;
String fullpath = tarFileSet.getFullpath();
if (fullpath.length() > 0)
{
vPath = fullpath;
}
else
{
// don't add "" to the archive
if (vPath.length() <= 0)
{
return;
}
if (file.isDirectory() && !vPath.endsWith("/"))
{
vPath += "/";
}
String prefix = tarFileSet.getPrefix();
// '/' is appended for compatibility with the zip task.
if (prefix.length() > 0 && !prefix.endsWith("/"))
{
prefix = prefix + "/";
}
vPath = prefix + vPath;
}