【发布时间】:2019-11-07 17:17:04
【问题描述】:
为什么import org.apache.commons.lang.StringUtils默认无法在android中导入。
我必须包含一个外部库吗?那么我在网上哪里可以找到那个库呢?
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;
}
}
【问题讨论】:
-
这是我必须下载所需 API 的网站吗:commons.apache.org/lang/download_lang.cgi
标签: android