code: private void importResource(Node parentNode, InputStream file_in, String resourceType, ArtifactDescriptor artifact)
              throws RepositoryException
     {
        // Note that artifactBean been initialized within constructor
        // resourceType can be jar, pom, metadata
  
        String filename;
        if (resourceType.equals("metadata"))
        {
           filename = "maven-metadata.xml";
        }
        else
        {
           filename = String.format("%s-%s.%s", artifact.getArtifactId(), artifact.getVersionId(), resourceType);
        }
  
        OutputStream fout = null;
        File tmp_file = null;
        try
        {
           String tmpFilename = getUniqueFilename(filename);
           tmp_file = File.createTempFile(tmpFilename, null);
           fout = new FileOutputStream(tmp_file);
           IOUtils.copy(file_in, fout);
           fout.flush();
        }
        catch (FileNotFoundException e)
        {
           LOG.error("Cannot create .tmp file for storing artifact", e);
        }
        catch (IOException e)
        {
           LOG.error("IO exception on .tmp file for storing artifact", e);
        }
        finally
        {
           IOUtils.closeQuietly(file_in);
           IOUtils.closeQuietly(fout);
        }
  
        writePrimaryContent(parentNode, filename, resourceType, tmp_file);
        writeChecksum(parentNode, filename, tmp_file, "SHA1");
  
        try
        {
           // and collect all garbage : temporary files
           FileUtils.forceDelete(tmp_file);
        }
        catch (IOException e)
        {
           LOG.error("Cannot delete tmp file", e);
        }
  
     }
docs: this method used for writing to repo jars, poms and their checksums