2.如果是PC端的,那么你要确定是Windows的,还是Mac OS的,或者是Linux的。前两者可能性最大。windows 的去学C#和Qt还有MFC,你现在掌握的C和C++肯定是不够的。Mac OS 去学Objective-C和Cocoa库/框架。
3.如果是移动端,你最容易的还是区别一下Android和IOS的。Android去学Java和Android对应的知识,比如去看第一行代码,对Android 有一个初步认识。IOS的话刚开始对C要求不高,你就先去学Objective-C。
4.可以查词的话你还的去学学算法,例如倒排索引,bfs,dfs等,刚开始可以直接上框架(可以了解一下solr和lucene),然后还得有词库。
楼主的url请求代码及接收解析有问题。
改版如下,仅供参考:
HttpUtil:
import java.io.DataOutputStreamimport java.io.IOException
import java.io.InputStreamReader
import java.net.HttpURLConnection
import java.net.MalformedURLException
import java.net.SocketTimeoutException
import java.net.URL
import org.apache.log4j.Logger
/**
* http发送Handler
*
* @author stone
* @version 2014-12-16
*/
public class HttpUtil {
private static Logger logger = Logger.getLogger(HttpUtil.class)
public static String send(String url_, String postData) {
StringBuilder sb = new StringBuilder()
try {
URL url = new URL(url_)
HttpURLConnection httpUrlConnection = (HttpURLConnection) url.openConnection()
httpUrlConnection.setConnectTimeout(5000)// 设置连接主机超时(单位:毫秒)
httpUrlConnection.setReadTimeout(5000)// 设置从主机读取数据超时(单位:毫秒)
httpUrlConnection.setDoOutput(true)
httpUrlConnection.setRequestMethod("POST")
httpUrlConnection.setUseCaches(false)
httpUrlConnection.setRequestProperty("Content-Type", "text/json")
httpUrlConnection.connect()
DataOutputStream out = new DataOutputStream(httpUrlConnection.getOutputStream())
out.write(postData.getBytes("utf-8"))
out.flush()
out.close()
int HttpResult = httpUrlConnection.getResponseCode()
if (HttpResult == HttpURLConnection.HTTP_OK) {
InputStreamReader br = new InputStreamReader(httpUrlConnection.getInputStream(), "utf-8")
int data = 0
while((data = br.read()) != -1) {
sb.append((char) data)
}
br.close()
}else {
logger.info("[i] server response info : " + httpUrlConnection.getResponseMessage())
}
httpUrlConnection.disconnect()
}catch (MalformedURLException e) {
logger.error("[e]: ---> catch some MalformedURLException : ", e)
}catch (SocketTimeoutException e) {
logger.error("[e]: ---> catch some SocketTimeoutException : ", e)
}catch (IOException e) {
logger.error("[e]: ---> catch some IOException : ", e)
}
return sb.toString()
}
}
TestYouDao:
public class TestYouDao {public static void main(String[] args) {
new ReadByGet().start()
}
}
class ReadByGet extends Thread {
public void run() {
try {
String url = "http://fanyi.youdao.com/openapi.do?keyfrom=adroid01&key=820574724&type=data&doctype=xml&version=1.1&q=good"
String result = HttpUtil.send(url, "")
System.out.println(result)
}catch (Exception e) {
e.printStackTrace()
}
}
}
程序运行结果如下:
不怎么明白题意,随便写一个public interface ShapePara {
public int getArea()//获得图形的面积
public int getCircumference()//获得图形的周长
}
public class Circle implements ShapePara {
public double radius//圆的半径
private double x//圆心的横坐标
protected double y//圆心的纵坐标
public Circle(double radius) {
super()
this.setRadius(radius)
this.setCenter(0.00, 0.00)
}
@Override
public int getArea() {
return (int) (Math.PI*Math.pow(radius, 2))
}
@Override
public int getCircumference() {
return (int) (Math.PI*2*radius)
}
//获取半径
public double getRadius(){
return this.radius
}
//设置圆心坐标
public void setCenter(double x, double y){
this.x = x
this.y = y
}
//设置radius域
public void setRadius(double radius){
this.radius = radius
}
public static void main(String[] args) {
Circle circle = new Circle(5.00)
}
}