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


Java IO类代码示例

本文整理汇总了Java中org.boon.IO的典型用法代码示例。如果您正苦于以下问题:Java IO类的具体用法?Java IO怎么用?Java IO使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: writeTo

import org.boon.IO; //导入依赖的package包/类
@Override
public void writeTo(final T t, final Class<?> aClass, final Type type, final Annotation[] annotations, final MediaType mediaType,
        final MultivaluedMap<String, Object> stringObjectMultivaluedMap, final OutputStream outputStream) throws IOException {
    IO.writeNoClose(outputStream, factory().create().serialize(t).toString());
}
 
开发者ID:rmannibucau,项目名称:boon-jaxrs-provider,代码行数:6,代码来源:BoonJsonMessageBodyWriter.java

示例2: main

import org.boon.IO; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static void main (String... args) {
       String path = "json/teams.json";
       puts ("PATH", path);
       puts ("CONTENTS of PATH", IO.read("json/teams.json"));

       /* Using Boon style parser (fast). */
       JsonParserAndMapper boonMapper = new JsonParserFactory().create();
       Object jsonObject = boonMapper.parseFile(path);


       /* Using Boon path. */
       puts ("teamInfo", atIndex(jsonObject, "teamInfo"));
       puts("Team Roster", atIndex(jsonObject, "teamInfo.teamRoster"));
       puts("Team Names", atIndex(jsonObject, "teamInfo.teamRoster.teamNames"));



       /* Using Boon style (easy) 2 parser. */
       jsonObject = Boon.jsonResource(path);


       /* Using Boon path. */
       puts ("teamInfo", atIndex(jsonObject, "teamInfo"));
       puts("Team Roster", atIndex(jsonObject, "teamInfo.teamRoster"));
       puts("Team Names", atIndex(jsonObject, "teamInfo.teamRoster.teamNames"));

       //There is also a Groovy style and a GSON style.

       List<String> teamNames = (List<String>) atIndex(jsonObject, "teamInfo.teamRoster.teamNames");

       puts("Team Names", teamNames);

       Set<String> teamNameSet = set(teamNames);

       puts ("Converted to a set", teamNameSet);

       TeamInfo teamInfo = fromMap((Map<String, Object>) atIndex(jsonObject, "teamInfo"), TeamInfo.class);
       puts(teamInfo);


       TeamRoster teamRoster = fromMap((Map<String, Object>) atIndex(jsonObject, "teamInfo.teamRoster"), TeamRoster.class);
       puts(teamRoster);

   }
 
开发者ID:East196,项目名称:maker,代码行数:46,代码来源:PartialDataTreeExample.java


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