本文整理汇总了Java中com.google.api.client.util.Charsets.UTF_8属性的典型用法代码示例。如果您正苦于以下问题:Java Charsets.UTF_8属性的具体用法?Java Charsets.UTF_8怎么用?Java Charsets.UTF_8使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.google.api.client.util.Charsets
的用法示例。
在下文中一共展示了Charsets.UTF_8属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onDisable
@Override
public void onDisable() {
try {
logCat.close();
String dat = new String(Serializer.<Map<String, UUID>>serializeBase64(uuid_map), Charsets.UTF_8);
if(uuidFile.exists()) {
BufferedWriter bw = new BufferedWriter(new FileWriter(uuidFile));
bw.write(dat);
bw.flush();
bw.close();
} else {
}
} catch (Exception | Error e) {
getLogger().log(Level.SEVERE, e.getMessage(), e);
}
}
示例2: fromStreamToString
/**
* Reads an input stream line by line and converts it into String.
* @param inputStream
* @throws IOException
*/
public static String fromStreamToString(InputStream inputStream)
throws IOException {
BufferedReader bufferedReader = null;
StringBuilder stringBuilder = new StringBuilder();
try {
String line;
bufferedReader = new BufferedReader(new InputStreamReader(inputStream, Charsets.UTF_8));
while ((line = bufferedReader.readLine()) != null) {
stringBuilder.append(line);
}
} finally {
if (bufferedReader != null) {
bufferedReader.close();
}
}
return stringBuilder.toString();
}
示例3: fromStreamToString
/**
* Reads an input stream line by line and converts it into String.
* @param inputStream
* @throws java.io.IOException
*/
public static String fromStreamToString(InputStream inputStream)
throws IOException {
BufferedReader bufferedReader = null;
StringBuilder stringBuilder = new StringBuilder();
try {
String line;
bufferedReader = new BufferedReader(new InputStreamReader(inputStream, Charsets.UTF_8));
while ((line = bufferedReader.readLine()) != null) {
stringBuilder.append(line);
}
} finally {
if (bufferedReader != null) {
bufferedReader.close();
}
}
return stringBuilder.toString();
}
示例4: onCreate
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mLogArea = new TextView(this);
ApiClientAsyncTask<Void, Void, String> task = new ApiClientAsyncTask<Void, Void, String>(this) {
@Override
protected String doInBackgroundConnected(Void[] params) {
StringBuffer result = new StringBuffer();
MetadataBuffer buffer = Drive.DriveApi.getAppFolder(getGoogleApiClient())
.listChildren(getGoogleApiClient()).await().getMetadataBuffer();
result.append("found " + buffer.getCount() + " files:\n");
for (Metadata m: buffer) {
DriveId id = m.getDriveId();
DriveFile file = Drive.DriveApi.getFile(getGoogleApiClient(), id);
Contents contents = file.openContents( getGoogleApiClient(),
DriveFile.MODE_READ_ONLY, null).await().getContents();
FileInputStream is = new FileInputStream(contents.getParcelFileDescriptor().getFileDescriptor());
try {
BufferedReader bf = new BufferedReader(new InputStreamReader(is, Charsets.UTF_8));
String line=null; StringBuffer sb=new StringBuffer();
while ((line=bf.readLine()) != null ) {
sb.append(line);
}
file.discardContents(getGoogleApiClient(), contents);
result.append("*** " + m.getTitle() + "/" + id + "/" + m.getFileSize() + "B:\n [" + sb.toString() + "]\n");
} catch (IOException e) {
throw new RuntimeException(e);
}
}
buffer.close();
return result.toString();
}
@Override
protected void onPostExecute(String s) {
if (mLogArea != null) {
mLogArea.append(s);
}
}
};
task.execute();
}