本文整理汇总了Java中org.apache.commons.codec.net.BCodec类的典型用法代码示例。如果您正苦于以下问题:Java BCodec类的具体用法?Java BCodec怎么用?Java BCodec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BCodec类属于org.apache.commons.codec.net包,在下文中一共展示了BCodec类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendData
import org.apache.commons.codec.net.BCodec; //导入依赖的package包/类
public void sendData() {
if (pd != null) {
String paraqms = "&dataid=" + pd.id;
switch (pd.dataType) {
case 0:
break;
case 1:
if (pd.pagerQuizItemsList.size() > 3) {
if (form.comboBoxPager.getSelectedItem() == null) {
return;
}
paraqms = paraqms + "&quizid=" + ((PagerQuizItems) (form.comboBoxPager
.getSelectedItem())).id;
} else {
String sel = "";
if (form.rbPager1.isSelected()) {
sel = form.rbPager1.getText();
} else if (form.rbPager2.isSelected()) {
sel = form.rbPager2.getText();
} else if (form.rbPager3.isSelected()) {
sel = form.rbPager3.getText();
}
for (PagerQuizItems q : pd.pagerQuizItemsList) {
if (q.itemText.equals(sel)) {
paraqms = paraqms + "&quizid=" + q.id;
break;
}
}
}
break;
case 2:
try {
paraqms =
paraqms + "&inputdata=" + new BCodec().encode(URLEncoder.encode(
form.textFieldPager.getText().length() > 545
? form.textFieldPager.getText()
.substring(0, 545) : form.textFieldPager.getText(), "utf8"),
"utf8");
} catch (EncoderException | UnsupportedEncodingException ex) {
}
break;
default:
throw new AssertionError();
}
try {
//http://localhost:8080/qskyapi/setpagerdata?qsysver=1.3.1&dataid=3&inputdata=Hello%20world!
//http://localhost:8080/qskyapi/setpagerdata?qsysver=1.3.1&dataid=2&quizid=3
final URL url = new URL(
PAGER_URL + "/qskyapi/setpagerdata?qsysver=" + FAbout.VERSION_
+ "&qplugins="
+ getMac() + "-" + getStat() + paraqms);
final HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("User-Agent", "Java bot");
conn.connect();
final int code = conn.getResponseCode();
if (code != 200) {
System.err.println("Strange! Pager not enabled. Returned code not 200.");
} else {
pd.checked = true;
}
conn.disconnect();
} catch (Exception e) {
System.err.println("Pager not enabled.");
form.bgPager.clearSelection();
return;
}
showData(true);
form.bgPager.clearSelection();
}
}