ImportJava.io.BufferedReader;ImportJava.io.InputStream;ImportJava.io.InputStreamReader;Importjava.net.HttpURLConnection;ImportJava.net.URL;Importjava.io.IOException; Public classprice{ Public StaticString url_prefix = "https://trade.chbtc.com/api/"; Public StaticString Api_domain = "http://api.chbtc.com"; Public Static floatEtcprice = 0; Public Static Booleannoticed =false; Public StaticString win = "You are rich, you are rich, you are rich, you rich, you rich, you rich, you rich, you rich, you rich, you rich, you rich, you rich, you rich, you rich, you rich, you rich, you wealthy, you rich, you rich, you are rich, , you are rich, you are rich, you are rich, you are rich, "; Public StaticString lose = "To compensate for crying, to compensate for crying, to compensate for crying, to compensate for crying, to compensate for crying, to compensate for crying, to compensate for crying, to compensate for crying, to compensate for crying, to compensate for crying, to compensate for crying, to compensate for crying, to compensate for crying, to compensate for crying, to compensate for crying, to pay the tears, to compensate for crying, to compensate for crying, To compensate for crying, to compensate for crying, to compensate for crying, "; Public Static voidMain (String []args) {Try{ while(true) {Testticker ("Btc_cny"); Testticker ("Ltc_cny"); Testticker ("Etc_cny"); Testticker ("Eth_cny"); System.out.println ((int) (742.103 * etcPrice-33200)); //System.out.println (""); if(!noticed) { if((742.103 * etcPrice-33200) > 5000) say (win); Else if((742.103 * etcPrice-33200) < 1000) say (lose); } thread.sleep (5000); } }Catch(Exception e) {e.printstacktrace (); } } /*** Get quotes*/ Public Static voidtestticker (String currency) {Try { //String currency = "BTC_CNY"; //Request AddressString url = api_domain+ "/data/v1/ticker?currency=" +currency; //Request TestString callback = Get (URL, "UTF-8"); intStart = Callback.indexof ("\" buy\ ": \" "); intEnd = Callback.indexof ("\", \ "High\" "); System.out.print (Currency.substring (0,3) + "" +callback.substring (start+7,end) + "\ T"); if(Currency.equals ("Etc_cny") ) {Etcprice= Float.valueof (callback.substring (start+7, end)); } } Catch(Exception ex) {ex.printstacktrace (); } } /** * * @paramUrlall *: Request interface *@paramCharSet *: Character encoding *@returnreturn JSON results*/ Public Staticstring Get (String Urlall, String charset) {BufferedReader reader=NULL; String result=NULL; StringBuffer SBF=NewStringBuffer (); String useragent= "mozilla/5.0 (Windows NT 6.1) applewebkit/537.36 (khtml, like Gecko) chrome/29.0.1547.66 safari/537.36";//Simulation Browser Try{URL URL=NewURL (Urlall); HttpURLConnection Connection=(httpurlconnection) URL. OpenConnection (); Connection.setrequestmethod ("GET"); Connection.setreadtimeout (30000); Connection.setconnecttimeout (30000); Connection.setrequestproperty ("User-agent", useragent); Connection.connect (); InputStream is=Connection.getinputstream (); Reader=NewBufferedReader (NewInputStreamReader (IS, CharSet)); String Strread=NULL; while((Strread = Reader.readline ())! =NULL) {sbf.append (strread); Sbf.append ("\ r \ n"); } reader.close (); Result=sbf.tostring (); } Catch(Exception e) {e.printstacktrace (); } returnresult; } Public Static voidsay (String content) {Try { //Execute Commandnoticed =true; Runtime.getruntime (). EXEC ("Say \" "+content+" \ ""); } Catch(IOException e) {e.printstacktrace (); } }}
Using the CHBTN API, you can voice reminders.
When used directly
Javac Price.java
Java Price
Automatic reading of virtual currency quotes and reminders of gadgets (Mac OSX)