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


Java UnsupportedEncodingException類代碼示例

本文整理匯總了Java中java.io.UnsupportedEncodingException的典型用法代碼示例。如果您正苦於以下問題:Java UnsupportedEncodingException類的具體用法?Java UnsupportedEncodingException怎麽用?Java UnsupportedEncodingException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


UnsupportedEncodingException類屬於java.io包,在下文中一共展示了UnsupportedEncodingException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: hashinate

import java.io.UnsupportedEncodingException; //導入依賴的package包/類
/**
 * Given an Object value, pick a partition to store the data. Currently only String objects can be hashed.
 *
 * @param value The value to hash.
 * @param partitionCount The number of partitions to choose from.
 * @return A value between 0 and partitionCount-1, hopefully pretty evenly
 * distributed.
 */
static int hashinate(Object value, int partitionCount) {
    if (value instanceof String) {
        String string = (String) value;
        try {
            byte bytes[] = string.getBytes("UTF-8");
            int hashCode = 0;
            int offset = 0;
            for (int ii = 0; ii < bytes.length; ii++) {
               hashCode = 31 * hashCode + bytes[offset++];
            }
            return java.lang.Math.abs(hashCode % partitionCount);
        } catch (UnsupportedEncodingException e) {
            hostLogger.l7dlog( Level.FATAL, LogKeys.host_TheHashinator_ExceptionHashingString.name(), new Object[] { string }, e);
            HStore.crashDB();
        }
    }
    hostLogger.l7dlog(Level.FATAL, LogKeys.host_TheHashinator_AttemptedToHashinateNonLongOrString.name(), new Object[] { value
            .getClass().getName() }, null);
    HStore.crashDB();
    return -1;
}
 
開發者ID:s-store,項目名稱:s-store,代碼行數:30,代碼來源:TheHashinator.java

示例2: setConfigurationXML64

import java.io.UnsupportedEncodingException; //導入依賴的package包/類
/**
 * Sets the configuration in XML in a Base64 decode form.
 * @param configurationXML64 the new configuration xm l64
 */
public void setConfigurationXML64(String[] configurationXML64) {
	
	String[] configXML = new String[configurationXML64.length];
	for (int i = 0; i < configurationXML64.length; i++) {
		try {
			if (configurationXML64[i]==null || configurationXML64[i].equals("")) {
				configXML[i] = null;
			} else {
				configXML[i] = new String(Base64.decodeBase64(configurationXML64[i].getBytes()), "UTF8");	
			}
			
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
	}
	
	this.getDynForm().setOntoArgsXML(configXML);
	this.getDynTableJPanel().refreshTableModel();
	if (this.getSelectedIndex()==1) {
		this.setXMLText();
	}
	
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:28,代碼來源:OntologyInstanceViewer.java

示例3: stringToMD5

import java.io.UnsupportedEncodingException; //導入依賴的package包/類
public static String stringToMD5(String string) {
    try {
        byte[] hash = MessageDigest.getInstance(Coder.KEY_MD5).digest(string.getBytes("UTF-8"));
        StringBuilder hex = new StringBuilder(hash.length * 2);
        for (byte b : hash) {
            if ((b & 255) < 16) {
                hex.append("0");
            }
            hex.append(Integer.toHexString(b & 255));
        }
        return hex.toString();
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
        return null;
    } catch (UnsupportedEncodingException e2) {
        e2.printStackTrace();
        return null;
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:20,代碼來源:MQUtils.java

示例4: getLabelFromBuiltIn

import java.io.UnsupportedEncodingException; //導入依賴的package包/類
private String getLabelFromBuiltIn(String uri){
	try {
		IRI iri = IRI.create(URLDecoder.decode(uri, "UTF-8"));
		
		// if IRI is built-in entity
		if(iri.isReservedVocabulary()) {
			// use the short form
			String label = sfp.getShortForm(iri);
			
			 // if it is a XSD numeric data type, we attach "value"
            if(uri.equals(XSD.nonNegativeInteger.getURI()) || uri.equals(XSD.integer.getURI())
            		|| uri.equals(XSD.negativeInteger.getURI()) || uri.equals(XSD.decimal.getURI())
            		|| uri.equals(XSD.xdouble.getURI()) || uri.equals(XSD.xfloat.getURI())
            		|| uri.equals(XSD.xint.getURI()) || uri.equals(XSD.xshort.getURI())
            		|| uri.equals(XSD.xbyte.getURI()) || uri.equals(XSD.xlong.getURI())
            		){
            	label += " value";
            }
            
            return label;
		}
	} catch (UnsupportedEncodingException e) {
		logger.error("Getting short form of " + uri + "failed.", e);
	}
	return null;
}
 
開發者ID:dice-group,項目名稱:RDF2PT,代碼行數:27,代碼來源:DefaultIRIConverter.java

示例5: sendChannelMsg

import java.io.UnsupportedEncodingException; //導入依賴的package包/類
private void sendChannelMsg(String msgStr) {
    RtcEngine rtcEngine = rtcEngine();
    if (mDataStreamId <= 0) {
        mDataStreamId = rtcEngine.createDataStream(true, true); // boolean reliable, boolean ordered
    }

    if (mDataStreamId < 0) {
        String errorMsg = "Create data stream error happened " + mDataStreamId;
        log.warn(errorMsg);
        showLongToast(errorMsg);
        return;
    }

    byte[] encodedMsg;
    try {
        encodedMsg = msgStr.getBytes("UTF-8");
    } catch (UnsupportedEncodingException e) {
        encodedMsg = msgStr.getBytes();
    }

    rtcEngine.sendStreamMessage(mDataStreamId, encodedMsg);
}
 
開發者ID:huangjingqiang,項目名稱:SWDemo,代碼行數:23,代碼來源:ChatActivity.java

示例6: getRequestData

import java.io.UnsupportedEncodingException; //導入依賴的package包/類
/**
 * 打包請求數據
 * 
 * @param type
 * @param paramPath
 * @return
 */
private static byte[] getRequestData(bussinessType type, String paramPath) {

    Map<String, String> dbInfo = getDBInfo(type);
    UAVHttpMessage request = new UAVHttpMessage();
    String dataStr = getFileData(paramPath);
    request.putRequest(DataStoreProtocol.MONGO_REQUEST_DATA, dataStr);
    request.putRequest(DataStoreProtocol.DATASTORE_NAME, dbInfo.get(k_dataStoreName));
    request.putRequest(DataStoreProtocol.MONGO_COLLECTION_NAME, dbInfo.get(k_conllectionName));
    String jsonStr = JSONHelper.toString(request);
    byte[] datab = null;
    try {
        datab = jsonStr.getBytes("utf-8");
    }
    catch (UnsupportedEncodingException e) {
        LOG.info("HttpTestApphub getRequestData \n" + e.getMessage());
    }

    return datab;
}
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:27,代碼來源:HttpTestApphubManager.java

示例7: sha256

import java.io.UnsupportedEncodingException; //導入依賴的package包/類
public static String sha256(String base) {
try {
    MessageDigest digest = MessageDigest.getInstance("SHA-256");
    byte[] hash = digest.digest(base.getBytes("UTF-8"));
    StringBuffer hexString = new StringBuffer();

    for (int i = 0; i < hash.length; i++) {
	String hex = Integer.toHexString(0xff & hash[i]);
	if (hex.length() == 1) {
	    hexString.append('0');
	}
	hexString.append(hex);
    }

    return hexString.toString();
} catch (UnsupportedEncodingException | NoSuchAlgorithmException ex) {
    throw new RuntimeException(ex);
}
   }
 
開發者ID:anrape,項目名稱:SpringWebAnuncio,代碼行數:20,代碼來源:Usuarios.java

示例8: parseText

import java.io.UnsupportedEncodingException; //導入依賴的package包/類
/**
 * Parse Text Frames.
 * 
 * @param bframes
 * @param offset
 * @param size
 * @param skip
 * @return
 */
protected String parseText(byte[] bframes, int offset, int size, int skip)
{
	String value = null;
	try
	{
		String enc = ENC_TYPES[0];
		if ( bframes[offset] >= 0 && bframes[offset] < 4 )
		{
			enc = ENC_TYPES[bframes[offset]];
		}
		value = new String(bframes, offset + skip, size - skip, enc);
		value = chopSubstring(value, 0, value.length());
	}
	catch (UnsupportedEncodingException e)
	{
		system.error("ID3v2 Encoding error: " + e.getMessage());
	}
	return value;
}
 
開發者ID:JacobRoth,項目名稱:romanov,代碼行數:29,代碼來源:MpegAudioFileReader.java

示例9: convert

import java.io.UnsupportedEncodingException; //導入依賴的package包/類
public ByteBuffer convert(Tag tag) throws UnsupportedEncodingException {
    ByteBuffer ogg = creator.convert(tag);
    int tagLength = ogg.capacity() + VorbisHeader.FIELD_PACKET_TYPE_LENGTH + VorbisHeader.FIELD_CAPTURE_PATTERN_LENGTH + OggVorbisCommentTagCreator.FIELD_FRAMING_BIT_LENGTH;

    ByteBuffer buf = ByteBuffer.allocate(tagLength);

    //[packet type=comment0x03]['vorbis']
    buf.put((byte) VorbisPacketType.COMMENT_HEADER.getType());
    buf.put(VorbisHeader.CAPTURE_PATTERN_AS_BYTES);

    //The actual tag
    buf.put(ogg);

    //Framing bit = 1
    buf.put(FRAMING_BIT_VALID_VALUE);

    buf.rewind();
    return buf;
}
 
開發者ID:openaudible,項目名稱:openaudible,代碼行數:20,代碼來源:OggVorbisCommentTagCreator.java

示例10: aesEncode

import java.io.UnsupportedEncodingException; //導入依賴的package包/類
/**
 *  可逆加密
 * @param secret
 * @param key
 * @return
 */
public static String aesEncode(String secret,String key){
    if (StringUtils.isEmpty(secret) || StringUtils.isEmpty(key)){
        return null;
    }

    byte[] retByte = new byte[0];
    try {
        retByte = AESEncode(secret.getBytes(chart_set_utf8),key);
    } catch (UnsupportedEncodingException e) {
        log.error(e.getMessage(),e);
    }
    if (retByte != null) {
        return bytesToHexString(retByte);
    }

    return null;
}
 
開發者ID:Awesky,項目名稱:awe-awesomesky,代碼行數:24,代碼來源:PasswdEncode.java

示例11: toTriple

import java.io.UnsupportedEncodingException; //導入依賴的package包/類
/**
 * This method converts a string (in n-triples format) into a Jena triple
 *
 * @param string containing single n-triples triple
 * @return Triple
 */
public static Triple toTriple(final String string) {
    // Create Jena model
    Model inputModel = createDefaultModel();
    try {
        // Load model with arg string (expecting n-triples)
        inputModel = inputModel.read(new StringInputStream(string), null, strLangNTriples);
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
    }

    // Since there is only one statement, get it
    final Statement stmt = inputModel.listStatements().nextStatement();

    // Return the Jena triple which the statement represents
    return stmt.asTriple();
}
 
開發者ID:duraspace,項目名稱:lambdora,代碼行數:23,代碼來源:TripleUtil.java

示例12: writeLenString

import java.io.UnsupportedEncodingException; //導入依賴的package包/類
final void writeLenString(String s, String encoding, String serverEncoding, SingleByteCharsetConverter converter, boolean parserKnowsUnicode,
        MySQLConnection conn) throws UnsupportedEncodingException, SQLException {
    byte[] b = null;

    if (converter != null) {
        b = converter.toBytes(s);
    } else {
        b = StringUtils.getBytes(s, encoding, serverEncoding, parserKnowsUnicode, conn, conn.getExceptionInterceptor());
    }

    int len = b.length;
    ensureCapacity(len + 9);
    writeFieldLength(len);
    System.arraycopy(b, 0, this.byteBuffer, this.position, len);
    this.position += len;
}
 
開發者ID:JuanJoseFJ,項目名稱:ProyectoPacientes,代碼行數:17,代碼來源:Buffer.java

示例13: main

import java.io.UnsupportedEncodingException; //導入依賴的package包/類
public static void main(String[] args) throws GeneralSecurityException, UnsupportedEncodingException {

        KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
        kpg.initialize(1024);
        KeyPair kp = kpg.genKeyPair();

        KeyFactory fact = KeyFactory.getInstance("RSA");
        RSAPublicKeySpec pub = fact.getKeySpec(kp.getPublic(),
                RSAPublicKeySpec.class);
        RSAPrivateKeySpec priv = fact.getKeySpec(kp.getPrivate(),
                RSAPrivateKeySpec.class);

        publicKey = fact.generatePublic(pub);
        privateKey = fact.generatePrivate(priv);

        String foo = rsaEncrypt("foo");

        byte[] decode = Base64.getDecoder().decode("foo");
        System.out.println(Base64.getEncoder().encodeToString(decode));

        System.out.println(rsaDecrypt(foo));

    }
 
開發者ID:daishicheng,項目名稱:outcomes,代碼行數:24,代碼來源:Main.java

示例14: getSHA512

import java.io.UnsupportedEncodingException; //導入依賴的package包/類
private String getSHA512(String passwordToHash) {
	String generatedPassword = null;
    try {
    	String salt = getKeyProvider().getKey(null);
        MessageDigest md = MessageDigest.getInstance("SHA-512");
        md.update(salt.getBytes("UTF-8"));
        byte[] bytes = md.digest(passwordToHash.getBytes("UTF-8"));
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < bytes.length; i++) {
           sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1));
        }
        generatedPassword = sb.toString();
        } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
       	 e.printStackTrace();
        }
	    return generatedPassword;
}
 
開發者ID:DescartesResearch,項目名稱:Pet-Supply-Store,代碼行數:18,代碼來源:SHASecurityProvider.java

示例15: getEligibleJobs

import java.io.UnsupportedEncodingException; //導入依賴的package包/類
public List<Job> getEligibleJobs(boolean male, int maxLength) {
    if(maxLength < 1)
        throw new IllegalArgumentException("Violation of precondidition: " +
                "getEligibleJobs. maxLength must be greater than 0.");

    List<Job> eligible = new ArrayList<>();
    List<Job> pool;
    if(male)
        pool = getMaleBaseClasses();
    else
        pool = getFemaleBaseClasses();
    try {
        for(Job j : pool) {
            if(j.getJid().getBytes("shift-jis").length <= maxLength && j.getItemType()
                    != ItemType.Staves && j.getItemType() != ItemType.Beaststone)
                eligible.add(j);
        }
    } catch(UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    return eligible;
}
 
開發者ID:thane98,項目名稱:3DSFE-Randomizer,代碼行數:23,代碼來源:FatesJobs.java


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