本文整理汇总了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());
}
示例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);
}