程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> PHP綜合 >> 一個塑料期貨交易程序分析圖程序(PHP+JAVA)

一個塑料期貨交易程序分析圖程序(PHP+JAVA)

編輯:PHP綜合

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<34100)
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<LINE;k1++)
hu2[k1]=he.zz(hu1[k1]);
/*
for(int k2=0;k2<10;k2++)
{
for(int k3=0;k3<14;k3++)
System.out.print(hu2[k2][k3]+"\t");
System.out.println("");
}
*/
int k2;
if(sta==0)
{
ori=hu2;
sta=1;
for(k2=0;k2<LINE;k2++)
he.writeinfo(hu2[k2],i);
}
else if(sta==1)
{
//he.writeinfo(hu2[0]);
//let's start the compare program,go go go
for(k2=0;k2<LINE;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<hello.length;i++)
hello[i]=hello[i].trim();
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<14;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"<form action=index.php method=post>
<input type=hidden name=GO value=1>

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved