这是我想要的输出
{"node":{"type":"community","field_incentives":{"und":[{"value":"fun"},{"value":"nice"}]},"field_community_email":{"und":[{"value":"some@one.com"}]}}}
Run Code Online (Sandbox Code Playgroud)
这是我的代码,但它似乎没有生成上面的输出.如果有更好更简单的方法,请告诉我.谢谢
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
JsonFactory f = new JsonFactory();
JsonGenerator g = f.createJsonGenerator(outputStream);
g.writeStartObject();
g.writeObjectFieldStart("node");
g.writeStringField("type", "community");
g.writeObjectFieldStart("field_incentives");
g.writeFieldName("und");
g.writeStartArray();
???I don't know how to make [{"value":"fun"},{"value":"nice"}]
g.writeEndArray();
g.writeEndObject();
g.close();
Run Code Online (Sandbox Code Playgroud) 我在 Windows 上有三个目录 A、B 和 C。我有一个文件存在于目录 A 中。我想要执行以下任务
步骤 1、2、3 工作正常,但不适用于步骤 4。文件存在并且可以写入、读取、执行。当我打开Windows资源管理器并尝试手动删除目录B中的文件时,它说该操作无法完成,因为它是在java平台SE二进制文件中打开的。下面是我复制文件的代码
FileInputStream in = new FileInputStream(source);
FileOutputStream out = new FileOutputStream(dest);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
Run Code Online (Sandbox Code Playgroud)
我正在使用 Java 6。你知道我如何完成步骤 4 吗?