为什么Android无法识别StringUtils Apache类? [英] Why StringUtils Apache class is not recognized in Android?
本文介绍了为什么Android无法识别StringUtils Apache类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么默认情况下 import org.apache.commons.lang.StringUtils 不能在android中导入.
Why import org.apache.commons.lang.StringUtils cannot be imported in android by default.
我必须包括一个外部图书馆吗?那我可以在网上找到那个图书馆?
Do i have to include an external library? Then where can i find that library on the web?
package com.myapps.urlencoding;
import android.app.Activity;
import org.apache.commons.lang.StringUtils;
public class EncodeIdUtil extends Activity {
/** Called when the activity is first created. */
private static Long multiplier=Long.parseLong("1zzzz",36);
/**
* Encodes the id.
* @param id the id to encode
* @return encoded string
*/
public static String encode(Long id) {
return StringUtils.reverse(Long.toString((id*multiplier), 35));
}
/**
* Decodes the encoded id.
* @param encodedId the encodedId to decode
* @return the Id
* @throws IllegalArgumentException if encodedId is not a validly encoded id.
*/
public static Long decode(String encodedId)
throws IllegalArgumentException {
long product;
try {
product = Long.parseLong(StringUtils.reverse(encodedId), 35);
} catch (Exception e) {
throw new IllegalArgumentException();
}
if ( 0 != product % multiplier || product < 0) {
throw new IllegalArgumentException();
}
return product/multiplier;
}
}
推荐答案
Apache Commons lang是一个单独的库.您可以在此处找到它.
Apache Commons lang is a separate library. You can find it here.
这篇关于为什么Android无法识别StringUtils Apache类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文