Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 Re:怎样编写实时获取其它网页内容的WEB PAGE? [Re:gus]
floater

Java Jedi

总版主


发贴: 3233
积分: 421
于 2003-06-18 01:29 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Yes, it has a link for daily quote. Fetch the info from below


package quote;

import java.util.*;
import utils.*;

public class YahooQuoteServer implements QuoteServer
{
public String getURL(KeyPairs quoteParams)
{
String startDate = quoteParams.getStringValue(START_DATE, "");
String endDate = quoteParams.getStringValue(END_DATE, "");
String stockSymbol = quoteParams.getStringValue(STOCK_SYMBOL, "");
String scale = quoteParams.getStringValue(TIME_INTERVAL, "d"); //default to daily

if (!checkDateFormat(startDate) || !checkDateFormat(endDate))
{
return WRONG_DATE_FORMAT;
}
StringTokenizer ssDate = new StringTokenizer(startDate, "/");
StringTokenizer seDate = new StringTokenizer(endDate, "/");
String sMonth = ssDate.nextToken();
String sDay = ssDate.nextToken();
String sYear = ssDate.nextToken();
String eMonth = seDate.nextToken();
String eDay = seDate.nextToken();
String eYear = seDate.nextToken();

String returnURL = new String("http://chart.yahoo.com/");
returnURL += "table.csv?&s=" + stockSymbol;
returnURL += "&a=" + sMonth + "&b=" + sDay + "&c=" + sYear;
returnURL += "&d=" + eMonth + "&e=" + eDay + "&f=" + eYear;
returnURL += "&g=" + scale + "&q=q&y=0&z=" + stockSymbol + "&x=.csv";

return returnURL;

}

// This will check the string to be in the format of XX/XX/XXXX
// where X is a digit 0-9
public static boolean checkDateFormat(String s)
{
String num = "0123456789";

if (s.length() != 10) return false;
if (num.indexOf(s.charAt(0)) == -1) return false;
if (num.indexOf(s.charAt(1)) == -1) return false;
if (s.charAt(2) != '/') return false;
if (num.indexOf(s.charAt(3)) == -1) return false;
if (num.indexOf(s.charAt(4)) == -1) return false;
if (s.charAt(5) != '/') return false;
if (num.indexOf(s.charAt(6)) == -1) return false;
if (num.indexOf(s.charAt(7)) == -1) return false;
if (num.indexOf(s.charAt(8)) == -1) return false;
if (num.indexOf(s.charAt(9)) == -1) return false;
return true;
}
}



"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
- Martin Fowler, Refactoring - Improving the Design of Existing Code

话题树型展开
人气 标题 作者 字数 发贴时间
5421 怎样编写实时获取其它网页内容的WEB PAGE? gus 55 2003-06-16 04:06
5164 Re:怎样编写实时获取其它网页内容的WEB PAGE? jameszhang 35 2003-06-16 10:52
4574 Re:怎样编写实时获取其它网页内容的WEB PAGE? floater 16 2003-06-16 22:44
5167 Re:怎样编写实时获取其它网页内容的WEB PAGE? jameszhang 77 2003-06-18 11:21
4460 Re:怎样编写实时获取其它网页内容的WEB PAGE? wduanyang 21 2003-06-17 09:50
4454 Re:怎样编写实时获取其它网页内容的WEB PAGE? caominfeng 15 2003-06-17 13:45
4635 Re:怎样编写实时获取其它网页内容的WEB PAGE? floater 2329 2003-06-18 01:29
4664 Re:怎样编写实时获取其它网页内容的WEB PAGE? 1255 47 2003-06-18 08:03
4636 Re:怎样编写实时获取其它网页内容的WEB PAGE? floater 219 2003-06-18 12:04

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923