打tar包工具TarUtil(7)

来源:互联网 发布:淘宝导出数据包 编辑:程序博客网 时间:2024/05/21 17:20

else
            {
                te.setMode(tarFileSet.getDirMode());
            }
            te.setUserName(tarFileSet.getUserName());
            te.setGroupName(tarFileSet.getGroup());
            te.setUserId(tarFileSet.getUid());
            te.setGroupId(tarFileSet.getGid());
           
            tOut.putNextEntry(te);
           
            if (!file.isDirectory())
            {
                fIn = new FileInputStream(file);
                final int byteSize = 8192;
                byte[] buffer = new byte[byteSize];
                int count = 0;
                do
                {
                    tOut.write(buffer, 0, count);
                    count = fIn.read(buffer, 0, buffer.length);
                } while (count != -1);
            }
           
            tOut.closeEntry();
        }
        finally
        {
            if (fIn != null)
            {
                fIn.close();
            }
        }
    }
   
    /**
     * Is the archive up to date in relationship to a list of files.
     * @param files the files to check
     * @return true if the archive is up to date.
     * @deprecated use the two-arg version instead.
     */
    protected boolean archiveIsUpToDate(String[] files)
    {
        return archiveIsUpToDate(files, baseDir);
    }