code: private void bulkloadTableFromResource(String table, Resource resource)
    {
      log.debug("bulk-loading data from '" + resource.getFilename()
        + "' into table '" + table + "'");
      String sql = "COPY \"" + table
        + "\" FROM STDIN WITH DELIMITER E'\t' NULL AS 'NULL'";
  
      try
      {
        // retrieve the currently open connection if running inside a transaction
        Connection originalCon = DataSourceUtils.getConnection(getDataSource());
        Connection con = originalCon;
        if (con instanceof DelegatingConnection)
        {
          DelegatingConnection<?> delCon = (DelegatingConnection<?>) con;
          con = delCon.getInnermostDelegate();
        }
  
        Preconditions.checkState(con instanceof PGConnection,
          "bulk-loading only works with a PostgreSQL JDBC connection");
  
        // Postgres JDBC4 8.4 driver now supports the copy API
        PGConnection pgCon = (PGConnection) con;
        pgCon.getCopyAPI().copyIn(sql, resource.getInputStream());
  
        DataSourceUtils.releaseConnection(originalCon, getDataSource());
  
      }
      catch (SQLException e)
      {
        throw new DatabaseAccessException(e);
      }
      catch (IOException e)
      {
        throw new FileAccessException(e);
      }
    }
docs: bulk-loads a table from a resource