本文整理匯總了Java中org.jivesoftware.smack.util.StringUtils.encodeBase64方法的典型用法代碼示例。如果您正苦於以下問題:Java StringUtils.encodeBase64方法的具體用法?Java StringUtils.encodeBase64怎麽用?Java StringUtils.encodeBase64使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jivesoftware.smack.util.StringUtils
的用法示例。
在下文中一共展示了StringUtils.encodeBase64方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: changeUserImage
import org.jivesoftware.smack.util.StringUtils; //導入方法依賴的package包/類
/**
* 修改用戶頭像
* @param xmppConnection
* @param file
*/
public static boolean changeUserImage(XMPPConnection xmppConnection,File file) {
try {
VCard vcard = new VCard();
vcard.load(xmppConnection);
byte[] bytes= MyFileUtil.getFileBytes(file);
String encodedImage = StringUtils.encodeBase64(bytes);
vcard.setAvatar(bytes, encodedImage);
vcard.setEncodedImage(encodedImage);
vcard.setField("PHOTO", "<TYPE>image/jpg</TYPE><BINVAL>" + encodedImage + "</BINVAL>", true);
vcard.save(xmppConnection);
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
示例2: changeUserImage
import org.jivesoftware.smack.util.StringUtils; //導入方法依賴的package包/類
/**
* 修改用戶頭像
*
* @param xmppConnection
* @param file
*/
public static boolean changeUserImage(XMPPConnection xmppConnection, File file) {
try {
VCard vcard = new VCard();
vcard.load(xmppConnection);
byte[] bytes = MyFileUtil.getFileBytes(file);
String encodedImage = StringUtils.encodeBase64(bytes);
vcard.setAvatar(bytes, encodedImage);
vcard.setEncodedImage(encodedImage);
vcard.setField("PHOTO", "<TYPE>image/jpg</TYPE><BINVAL>" + encodedImage + "</BINVAL>", true);
vcard.save(xmppConnection);
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
示例3: flushBuffer
import org.jivesoftware.smack.util.StringUtils; //導入方法依賴的package包/類
private synchronized void flushBuffer() throws IOException {
// do nothing if no data to send available
if (bufferPointer == 0) {
return;
}
// create data packet
String enc = StringUtils.encodeBase64(buffer, 0, bufferPointer, false);
DataPacketExtension data = new DataPacketExtension(byteStreamRequest.getSessionID(),
this.seq, enc);
// write to XMPP stream
writeToXML(data);
// reset buffer pointer
bufferPointer = 0;
// increment sequence, considering sequence overflow
this.seq = (this.seq + 1 == 65535 ? 0 : this.seq + 1);
}
示例4: challengeReceived
import org.jivesoftware.smack.util.StringUtils; //導入方法依賴的package包/類
/**
* The server is challenging the SASL mechanism for the stanza he just sent. Send a
* response to the server's challenge.
*
* @param challenge a base64 encoded string representing the challenge.
* @throws IOException if an exception sending the response occurs.
*/
public void challengeReceived(String challenge) throws IOException {
byte response[];
if(challenge != null) {
response = sc.evaluateChallenge(StringUtils.decodeBase64(challenge));
} else {
response = sc.evaluateChallenge(new byte[0]);
}
Packet responseStanza;
if (response == null) {
responseStanza = new Response();
}
else {
responseStanza = new Response(StringUtils.encodeBase64(response, false));
}
// Send the authentication to the server
getSASLAuthentication().send(responseStanza);
}
示例5: setAvatar
import org.jivesoftware.smack.util.StringUtils; //導入方法依賴的package包/類
/**
* Specify the bytes for the avatar to use.
*
* @param bytes the bytes of the avatar.
*/
public void setAvatar(byte[] bytes) {
if (bytes == null) {
// Remove avatar (if any) from mappings
otherUnescapableFields.remove("PHOTO");
return;
}
// Otherwise, add to mappings.
String encodedImage = StringUtils.encodeBase64(bytes);
avatar = encodedImage;
setField("PHOTO", "<TYPE>image/jpeg</TYPE><BINVAL>" + encodedImage + "</BINVAL>", true);
}
示例6: authenticate
import org.jivesoftware.smack.util.StringUtils; //導入方法依賴的package包/類
protected void authenticate() throws IOException, XMPPException {
String authenticationText = null;
try {
if(sc.hasInitialResponse()) {
byte[] response = sc.evaluateChallenge(new byte[0]);
authenticationText = StringUtils.encodeBase64(response, false);
}
} catch (SaslException e) {
throw new XMPPException("SASL authentication failed", e);
}
// Send the authentication to the server
getSASLAuthentication().send(new AuthMechanism(getName(), authenticationText));
}
示例7: setAvatar
import org.jivesoftware.smack.util.StringUtils; //導入方法依賴的package包/類
/**
* Specify the bytes for the avatar to use as well as the mime type.
*
* @param bytes the bytes of the avatar.
* @param mimeType the mime type of the avatar.
*/
public void setAvatar(byte[] bytes, String mimeType) {
// If bytes is null, remove the avatar
if (bytes == null) {
removeAvatar();
return;
}
// Otherwise, add to mappings.
String encodedImage = StringUtils.encodeBase64(bytes);
setAvatar(encodedImage, mimeType);
}
示例8: encodeSubgraph
import org.jivesoftware.smack.util.StringUtils; //導入方法依賴的package包/類
public static String encodeSubgraph(StorageGraph sgraph)
{
SubgraphSerializer ser = new SubgraphSerializer();
ByteArrayOutputStream out = new ByteArrayOutputStream();
try
{
ser.writeData(out, sgraph);
}
catch (IOException e)
{
throw new RuntimeException(e);
}
return StringUtils.encodeBase64(out.toByteArray());
}