角度×円周率÷180
public static double deg2rad(double degree) {
return degree * Math.PI / 180;
}
弧度÷円周率×180
public static double rad2deg(double radian) {
return radian / Math.PI * 180;
}
public class StringUtility {
/** HTMLエンコードが必要な文字 **/
static char[] htmlEncChar = { '&', '"', '<', '>' };
/** HTMLエンコードした文字列 **/
static String[] htmlEncStr = { "&", """, "<", ">" };
/**
* デフォルトコンストラクタでのオブジェクト生成を抑止。
*/
private StringUtility() {}
/**
* 指定された文字列中の&"<>を&"<>に変換する。
* @param String data 変換対象の文字列。
* @return 変換後の文字列。
*/
public static String htmlEncode(String strIn) {
if (strIn == null || strIn.trim().length() <= 0) {
return strIn;
}
char[] fromChar = strIn.toCharArray();
StringBuffer buf = new StringBuffer();
for (int i = 0; i < fromChar.length; ++i) {
boolean found = false;
for (int j = 0; j < htmlEncChar.length; ++j) {
if (fromChar[i] == htmlEncChar[j]) {
buf.append(htmlEncStr[j]);
found = true;
}
}
if (!found) {
buf.append(fromChar[i]);
}
}
return buf.toString();
}
}
あなたのご意見・感想をお送りください。
何かの理由でうまく送れない場合にはメール
でお願いします。