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


Java ContentWriter.guessEncoding方法代码示例

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


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

示例1: testAlf6560MimetypeSetting

import org.alfresco.service.cmr.repository.ContentWriter; //导入方法依赖的package包/类
public void testAlf6560MimetypeSetting() throws Exception
{
    FileInfo fileInfo = fileFolderService.create(workingRootNodeRef, "Something.html", ContentModel.TYPE_CONTENT);
    NodeRef fileNodeRef = fileInfo.getNodeRef();
    
    // Write the content but without setting the mimetype
    ContentWriter writer = fileFolderService.getWriter(fileNodeRef);
    writer.putContent("CONTENT");
    
    ContentReader reader = fileFolderService.getReader(fileNodeRef);
    assertEquals("Mimetype was not automatically set", MimetypeMap.MIMETYPE_HTML, reader.getMimetype());
    
    
    // Now ask for encoding too
    writer = fileFolderService.getWriter(fileNodeRef);
    writer.guessEncoding();
    OutputStream out = writer.getContentOutputStream();
    out.write( "<html><body>hall\u00e5 v\u00e4rlden</body></html>".getBytes("UnicodeBig") );
    out.close();
    
    reader = fileFolderService.getReader(fileNodeRef);
    assertEquals("Mimetype was not automatically set", MimetypeMap.MIMETYPE_HTML, reader.getMimetype());
    assertEquals("Encoding was not automatically set", "UTF-16BE", reader.getEncoding());
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:FileFolderServiceImplTest.java

示例2: writeData

import org.alfresco.service.cmr.repository.ContentWriter; //导入方法依赖的package包/类
private void writeData(String fileName, final NodeRef fileNodeRef) 
{
    nodeService.addAspect(fileNodeRef, ContentModel.ASPECT_NO_CONTENT, null);
    // Access the content
    ContentWriter writer = fileFolderService.getWriter(fileNodeRef);

    // set content properties
    writer.guessMimetype(fileName);
    writer.guessEncoding();

    // Get the input stream from the request data
    InputStream is = getClass().getClassLoader().getResourceAsStream(
          "farmers_markets_list_2003.doc");

    // Write the new data to the content node
    writer.putContent(is);

    // write info about author
    AuthenticationUtil.pushAuthentication();
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.SYSTEM_USER_NAME);
    this.transactionService.getRetryingTransactionHelper().doInTransaction(
    new RetryingTransactionCallback<Void>() {
       public Void execute() throws Throwable 
       {
          // Create the action
          Action action = actionService.createAction(ContentMetadataExtracter.EXECUTOR_NAME);
          try 
          {
             actionService.executeAction(action, fileNodeRef);
          }
          catch (Throwable th) 
          {
             // do nothing
          }
          return null;
       }
    });
    AuthenticationUtil.popAuthentication();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:40,代码来源:LockableAspectInterceptorTest.java


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