이유 가져 오기 org.apache.commons.lang.StringUtils은 기본적으로 android에서 가져올 수 없습니다.Android에서 StringUtils Apache 클래스가 인식되지 않는 이유는 무엇입니까?
외부 라이브러리를 포함해야합니까? 그렇다면 웹에서 라이브러리를 어디에서 찾을 수 있습니까?
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를 다운로드해야하는 사이트입니까? http://commons.apache.org/lang/download_lang.cgi –