当前位置: 首页>>代码示例>>Java>>正文


Java FileUtils.startNewUtf8File方法代码示例

本文整理汇总了Java中org.gbif.utils.file.FileUtils.startNewUtf8File方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.startNewUtf8File方法的具体用法?Java FileUtils.startNewUtf8File怎么用?Java FileUtils.startNewUtf8File使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.gbif.utils.file.FileUtils的用法示例。


在下文中一共展示了FileUtils.startNewUtf8File方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateMetadata

import org.gbif.utils.file.FileUtils; //导入方法依赖的package包/类
/**
 * Creates a single EML metadata file for the entire archive.
 * Make sure we execute this method AFTER building the constituents metadata which adds to our dataset instance.
 */
private void generateMetadata() {
  LOG.info("Add query dataset metadata to archive");
  try {
    // Random UUID use because the downloadKey is not a string in UUID format
    Download download = occurrenceDownloadService.get(configuration.getDownloadKey());
    String downloadUniqueID = configuration.getDownloadKey();
    if (download.getDoi() != null) {
      downloadUniqueID = download.getDoi().getDoiName();
      dataset.setDoi(download.getDoi());
      Identifier identifier = new Identifier();
      identifier.setCreated(download.getCreated());
      identifier.setIdentifier(configuration.getDownloadKey());
      identifier.setType(IdentifierType.GBIF_PORTAL);
      dataset.setIdentifiers(Lists.newArrayList(identifier));
    }
    dataset.setKey(UUID.randomUUID());
    dataset.setTitle(String.format(DATASET_TITLE_FMT, downloadUniqueID));
    dataset.setDescription(getDatasetDescription());
    dataset.setCreated(download.getCreated());
    Citation citation = new Citation(String.format(DATASET_TITLE_FMT, downloadUniqueID), downloadUniqueID);
    dataset.setCitation(citation);
    // can we derive a link from the query to set the dataset.homepage?
    dataset.setPubDate(download.getCreated());
    dataset.setDataLanguage(Language.ENGLISH);
    dataset.setType(DatasetType.OCCURRENCE);
    dataset.getDataDescriptions().add(createDataDescription());
    //TODO: use new license field once available
    if (download.getLicense().isConcrete()) {
      dataset.setRights(String.format(RIGHTS, download.getLicense().getLicenseTitle(), download.getLicense().getLicenseUrl()));
    }
    dataset.getContacts()
      .add(DwcaContactsUtil.createContact(DOWNLOAD_CONTACT_SERVICE,
                                          DOWNLOAD_CONTACT_EMAIL,
                                          ContactType.ORIGINATOR,
                                          true));
    dataset.getContacts()
      .add(DwcaContactsUtil.createContact(DOWNLOAD_CONTACT_SERVICE,
                                          DOWNLOAD_CONTACT_EMAIL,
                                          ContactType.ADMINISTRATIVE_POINT_OF_CONTACT,
                                          true));
    dataset.getContacts()
      .add(DwcaContactsUtil.createContact(DOWNLOAD_CONTACT_SERVICE,
                                          DOWNLOAD_CONTACT_EMAIL,
                                          ContactType.METADATA_AUTHOR,
                                          true));

    File eml = new File(archiveDir, METADATA_FILENAME);
    Writer writer = FileUtils.startNewUtf8File(eml);
    EML_WRITER.writeTo(dataset, writer);

  } catch (Exception e) {
    LOG.error("Failed to write query result dataset EML file", e);
  }
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:59,代码来源:DwcaArchiveBuilder.java


注:本文中的org.gbif.utils.file.FileUtils.startNewUtf8File方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。