當前位置: 首頁>>代碼示例>>Java>>正文


Java StringUtils.encodeBase64方法代碼示例

本文整理匯總了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;
    }
}
 
開發者ID:FanHuaRan,項目名稱:SmackStudy,代碼行數:22,代碼來源:XMPPUtil.java

示例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;
    }
}
 
開發者ID:FanHuaRan,項目名稱:SmackStudy,代碼行數:23,代碼來源:XMPPUtil.java

示例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);

        }
 
開發者ID:ice-coffee,項目名稱:EIM,代碼行數:23,代碼來源:InBandBytestreamSession.java

示例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);
}
 
開發者ID:CJC-ivotten,項目名稱:androidPN-client.,代碼行數:27,代碼來源:SASLMechanism.java

示例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);
}
 
開發者ID:ice-coffee,項目名稱:EIM,代碼行數:19,代碼來源:VCard.java

示例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));
}
 
開發者ID:CJC-ivotten,項目名稱:androidPN-client.,代碼行數:15,代碼來源:SASLMechanism.java

示例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);
}
 
開發者ID:CJC-ivotten,項目名稱:androidPN-client.,代碼行數:19,代碼來源:VCard.java

示例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());
}
 
開發者ID:hypergraphdb,項目名稱:hypergraphdb,代碼行數:15,代碼來源:SubgraphManager.java


注:本文中的org.jivesoftware.smack.util.StringUtils.encodeBase64方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。