当前位置: 首页>>代码示例>>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;未经允许,请勿转载。