本文整理汇总了Java中com.google.api.client.json.JsonGenerator类的典型用法代码示例。如果您正苦于以下问题:Java JsonGenerator类的具体用法?Java JsonGenerator怎么用?Java JsonGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JsonGenerator类属于com.google.api.client.json包,在下文中一共展示了JsonGenerator类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: unauthorized
import com.google.api.client.json.JsonGenerator; //导入依赖的package包/类
protected void unauthorized(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
String userAgent = req.getHeader("User-Agent");
resp.setHeader("Content-Type", "text/javascript");
resp.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
JsonGenerator generator = jsonFactory.createJsonGenerator(resp.getWriter());
generator.writeStartObject();
generator.writeFieldName("error");
generator.writeString("Login required.");
generator.writeFieldName("q");
generator.writeString(req.getQueryString());
generator.writeFieldName("agent");
generator.writeString(userAgent);
generator.writeEndObject();
generator.flush();
}
开发者ID:HotswapProjects,项目名称:HotswapAgentExamples,代码行数:20,代码来源:UnauthorizedServlet.java
示例2: createTempJsonKeyFile
import com.google.api.client.json.JsonGenerator; //导入依赖的package包/类
public static String createTempJsonKeyFile(String clientEmail,
PrivateKey privateKey) throws
IOException {
final File tempJsonKey = File.createTempFile("temp-key", ".json",
getTempFolder());
JsonGenerator jsonGenerator = null;
try {
jsonGenerator = new JacksonFactory()
.createJsonGenerator(new FileOutputStream(tempJsonKey),
Charset.forName("UTF-8"));
jsonGenerator.enablePrettyPrint();
jsonGenerator.serialize(createJsonKey(clientEmail, privateKey));
} finally {
if (jsonGenerator != null) {
jsonGenerator.close();
}
}
return tempJsonKey.getAbsolutePath();
}
开发者ID:jenkinsci,项目名称:google-oauth-plugin,代码行数:20,代码来源:JsonServiceAccountConfigTestUtil.java
示例3: createTempLegacyJsonKeyFileWithMissingClientEmail
import com.google.api.client.json.JsonGenerator; //导入依赖的package包/类
public static String createTempLegacyJsonKeyFileWithMissingClientEmail()
throws IOException {
final File tempLegacyJsonKey =
File.createTempFile("temp-legacykey", ".json", getTempFolder());
JsonGenerator jsonGenerator = null;
try {
jsonGenerator = new JacksonFactory()
.createJsonGenerator(new FileOutputStream(tempLegacyJsonKey),
Charset.forName("UTF-8"));
jsonGenerator.enablePrettyPrint();
jsonGenerator.serialize(createLegacyJsonKeyWithMissingClientEmail());
} finally {
if (jsonGenerator != null) {
jsonGenerator.close();
}
}
return tempLegacyJsonKey.getAbsolutePath();
}
开发者ID:jenkinsci,项目名称:google-oauth-plugin,代码行数:19,代码来源:LegacyJsonServiceAccountConfigUtil.java
示例4: save
import com.google.api.client.json.JsonGenerator; //导入依赖的package包/类
private void save() throws IOException {
FileOutputStream fos = new FileOutputStream(file);
try {
JsonGenerator generator = jsonFactory.createJsonGenerator(fos, Charsets.UTF_8);
generator.serialize(credentials);
generator.close();
} finally {
fos.close();
}
}
开发者ID:agilie,项目名称:dribbble-android-sdk,代码行数:11,代码来源:FileCredentialStore.java
示例5: save
import com.google.api.client.json.JsonGenerator; //导入依赖的package包/类
public void save() {
try (FileOutputStream fos = new FileOutputStream(configFile)) {
JsonGenerator generator = Start.JSON_FACTORY.createJsonGenerator(
fos, Charset.forName("UTF-8"));
generator.enablePrettyPrint();
generator.serialize(this);
generator.close();
} catch (IOException ex) {
throw new RuntimeException(ex);
}
for(ConfigChangeListener listener : this.listeners) {
listener.onConfigChanged();
}
}
开发者ID:r04r,项目名称:KSPModClient,代码行数:16,代码来源:Config.java
示例6: saveEnabledMods
import com.google.api.client.json.JsonGenerator; //导入依赖的package包/类
private void saveEnabledMods(EnabledMods mods) throws IOException {
try (FileOutputStream fos = new FileOutputStream(
enabledModsFile.toFile())) {
JsonGenerator generator = Start.JSON_FACTORY.createJsonGenerator(
fos, Charset.forName("UTF-8"));
generator.enablePrettyPrint();
generator.serialize(mods);
generator.close();
_enabledMods = mods;
}
}
开发者ID:r04r,项目名称:KSPModClient,代码行数:12,代码来源:ModManager.java
示例7: createTempLegacyJsonKeyFile
import com.google.api.client.json.JsonGenerator; //导入依赖的package包/类
public static String createTempLegacyJsonKeyFile(String clientEmail)
throws IOException {
final File tempLegacyJsonKey =
File.createTempFile("temp-legacykey", ".json", getTempFolder());
final JsonGenerator jsonGenerator = new JacksonFactory()
.createJsonGenerator(new FileOutputStream(tempLegacyJsonKey),
Charset.forName("UTF-8"));
jsonGenerator.enablePrettyPrint();
jsonGenerator.serialize(createLegacyJsonKey(clientEmail));
jsonGenerator.close();
return tempLegacyJsonKey.getAbsolutePath();
}
开发者ID:jenkinsci,项目名称:google-oauth-plugin,代码行数:13,代码来源:LegacyJsonServiceAccountConfigUtil.java
示例8: createTempLegacyJsonKeyFileWithMissingWebObject
import com.google.api.client.json.JsonGenerator; //导入依赖的package包/类
public static String createTempLegacyJsonKeyFileWithMissingWebObject()
throws IOException {
final File tempLegacyJsonKey =
File.createTempFile("temp-legacykey", ".json", getTempFolder());
final JsonGenerator jsonGenerator = new JacksonFactory()
.createJsonGenerator(new FileOutputStream(tempLegacyJsonKey),
Charset.forName("UTF-8"));
jsonGenerator.enablePrettyPrint();
jsonGenerator.serialize(createLegacyJsonKeyWithMissingWebObject());
jsonGenerator.close();
return tempLegacyJsonKey.getAbsolutePath();
}
开发者ID:jenkinsci,项目名称:google-oauth-plugin,代码行数:13,代码来源:LegacyJsonServiceAccountConfigUtil.java
示例9: storeClientToken
import com.google.api.client.json.JsonGenerator; //导入依赖的package包/类
private void storeClientToken(final JsonFactory jsonFactory) throws IOException
{
final StringWriter jsonTrWriter = new StringWriter();
final JsonGenerator generator = jsonFactory.createJsonGenerator(jsonTrWriter);
generator.serialize(clientToken);
generator.flush();
generator.close();
FileUtils.writeStringToFile(clientTokenPath.toFile(), jsonTrWriter.toString(), charset);
}
开发者ID:HolgerHees,项目名称:cloudsync,代码行数:11,代码来源:RemoteGoogleDriveConnector.java
示例10: writeToken
import com.google.api.client.json.JsonGenerator; //导入依赖的package包/类
private void writeToken() throws IOException {
try (OutputStream outputStream = new FileOutputStream(tokenFile);
OutputStreamWriter outputWriter = new OutputStreamWriter(outputStream)) {
JsonGenerator generator = new JacksonFactory().createJsonGenerator(outputWriter);
generator.enablePrettyPrint();
generator.serialize(token);
generator.flush();
}
}
开发者ID:googleads,项目名称:googleads-shopping-samples,代码行数:10,代码来源:ConfigDataStoreFactory.java
示例11: downloadMod
import com.google.api.client.json.JsonGenerator; //导入依赖的package包/类
private File downloadMod(ApiMod mod) throws IOException {
System.out.println("Starting download for " + mod.getTitle());
String url = mod.getDownloadUrl();
HttpURLConnection connection;
boolean redirect = false;
do {
URL website = new URL(url);
System.out.println("Accessing " + url);
connection = (HttpURLConnection) website.openConnection();
connection.setInstanceFollowRedirects(false);
String location = connection.getHeaderField("Location");
if (location != null) {
connection.disconnect();
url = location.replaceAll("(?i)/(\\d+)\\\\(\\d+)/", "/$1/$2/");
if (!url.startsWith("http"))
url = "http:" + url;
URL u = new URL(url);
String[] parts = u.getPath().split("/");
for (int i = 0; i < parts.length; i++) {
parts[i] = CharEscapers.escapeUriPath(parts[i]);
}
url = u.getProtocol() + "://" + u.getHost() + "/"
+ Joiner.on('/').join(parts)
+ (u.getQuery() != null ? "?" + u.getQuery() : "");
redirect = true;
} else {
redirect = false;
}
} while (redirect);
MessageDigest digest;
try {
digest = MessageDigest.getInstance("SHA1");
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
File cacheFile = new File(Config.cachedir, "mod-" + mod.getId()
+ ".zip");
File cacheConfigFile = new File(Config.cachedir, mod.getInfoName());
try (DigestInputStream dis = new DigestInputStream(
connection.getInputStream(), digest);
FileOutputStream fos = new FileOutputStream(cacheFile)) {
IOUtils.copy(dis, fos);
}
try (FileOutputStream fos = new FileOutputStream(cacheConfigFile)) {
JsonGenerator generator = Start.JSON_FACTORY.createJsonGenerator(
fos, Charset.forName("UTF-8"));
generator.enablePrettyPrint();
generator.serialize(mod);
generator.close();
}
System.out.println("Download finished "
+ byteArray2Hex(digest.digest()) + " vs " + mod.getSha1sum());
return cacheFile;
}
开发者ID:r04r,项目名称:KSPModClient,代码行数:65,代码来源:ModManager.java
注:本文中的com.google.api.client.json.JsonGenerator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论