程序
PHP+JAVA的程序
.....................
Java Program:
/*
以下程序为余姚塑料城期货交易数据的定时追踪分析程序
是对数据的初步分析,绘图分析则交给进一步的php程序来完成
本程序完成策划于2005-5-17(友谊日)
本程序可以作为K线图原始数据库
*/
import java.net.*;
import java.io.*;
import java.nio.*;
import java.text.*;
import java.util.*;
import java.util.Date;
import java.util.regex.*;
class suliao
{
final static int LINE=11;
public static void main(String args[])
{
String url="http://www.ex-cp.com//yy_data/quot.txt";
String url1="http://www.51kk7.com/Forum/User/CompanyInfo.aspx?companyId=0";
for(;;)
{
try
{
Thread.sleep(10000);
String ori[][]=new String[LINE][14];
int sta=0;
//
for(;;)
{
Thread.sleep(1000);
Date date;
SimpleDateFormat hua=new SimpleDateFormat("H m s");
String time=hua.format(date=new Date());
String[] hua1=time.split("\s");
int i=Integer.parseInt(hua1[0])*3600+Integer.parseInt(hua1[1])*60+Integer.parseInt(hua1[2]);
if(i break;
if(i>39900)
break;
URL hp=new URL(url);
URLConnection hpCon=hp.openConnection();
int len=hpCon.getContentLength();
InputStream input=hpCon.getInputStream();
int c;
StringBuffer hu=new StringBuffer("");
String hu1[]=new String[LINE];
int k=0;
while(((c=input.read())!=-1)&&(--len>0))
{
if(c==10)
{
hu1[k]=hu.toString();
hu=new StringBuffer("");
k++;
}
else
{
char c1=(char)c;
hu.append(c1);
}
}
hu1[LINE-1]=hu.toString();
String hu2[][]=new String[LINE][14];
suliao he=new suliao();
for(int k1=0;k1
/*
for(int k2=0;k2 {
for(int k3=0;k3 System.out.print(hu2[k2][k3]+"\t");
System.out.println("");
}
*/
int k2;
if(sta==0)
{
ori=hu2;
sta=1;
for(k2=0;k2
}
else if(sta==1)
{
//he.writeinfo(hu2[0]);
//let's start the compare program,go go go
for(k2=0;k2
//System.out.println(hu2[k2][12]+"-"+ori[k2][12]);
if(true)//he.zv(hu2[k2][12])!=he.zv(ori[k2][12]))
{
he.writeinfo(hu2[k2],i);
}
}
ori=hu2;
}
}
//
}
catch(Exception e)
{
//System.out.println("wrong wrong wrong!!!");
e.printStackTrace();
}
}
}
public String[] zz(String a)
{
String[] hello=a.split("\,");
for(int i=0;i
return hello;
}
public int zv(String a)
{
return Integer.parseInt(a);
}
public void writeinfo(String[] a,int i)//写入文本数据库中
{
Calendar cn=Calendar.getInstance();
int mon=cn.get(Calendar.MONTH)+1;
String dir=cn.get(Calendar.YEAR)+"-"+mon+"-"+cn.get(Calendar.DAY_OF_MONTH);
String file=cn.get(Calendar.YEAR)+"-"+mon+"-"+cn.get(Calendar.DAY_OF_MONTH)+"/"+a[0]+".txt";
File hu=new File(file);
File ha=new File(dir);
try
{
if(!ha.exists())
ha.mkdir();
if(!hu.exists())
hu.createNewFile();
//Date date;
//SimpleDateFormat hua=new SimpleDateFormat("H m s");
//String time=hua.format(date=new Date());
//String[] hua1=time.split("\s");
//int i=Integer.parseInt(hua1[0])*3600+Integer.parseInt(hua1[1])*60+Integer.parseInt(hua1[2]);
int k;
StringBuffer kv=new StringBuffer("");
for(k=0;k {
kv.append(a[k]+"\t");
}
kv.append(i+"\n");
System.out.println(kv.toString());
FileWriter rar=new FileWriter(hu,true);
rar.write(kv.toString());
rar.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
PHP Program
$GO=$_POST['GO'];
if(!$GO)
$GO=$_GET['GO'];
if($GO==1)
{
$dir=$_POST['time'];
$file1=$_POST['file'];
$handle=opendir('./'.$dir);
print"
成交量 | 报价 | 时间 |
".$hu[$i][0]." | ".$hu[$i][1]." | ".$TIME." |