就是我用
StreamReader sr = new StreamReader( @"D:\ForecastResult.dat", Encoding.GetEncoding("GB2312") );
char[] tempBuffer=new char[100];
StringBuilder result = new StringBuilder("");
string t;
int j=0,k=4;
if (sr.Read(tempBuffer,j,k) != 0)
{
result.Append(tempBuffer);
t = result.ToString();
richTextBox1.AppendText(t);
richTextBox1.AppendText("-");
}
读取了那个文件里的前四个字符,然后又自己额外加了一个"-",想接着读2个字符,请问怎么办到啊?
StreamReader sr = new StreamReader( @"D:\ForecastResult.dat", Encoding.GetEncoding("GB2312") );
char[] tempBuffer=new char[100];
StringBuilder result = new StringBuilder("");
string t;
int j=0,k=4;
if (sr.Read(tempBuffer,j,k) != 0)
{
result.Append(tempBuffer);
t = result.ToString();
richTextBox1.AppendText(t);
richTextBox1.AppendText("-");
}
读取了那个文件里的前四个字符,然后又自己额外加了一个"-",想接着读2个字符,请问怎么办到啊?
if (sr.Read(tempBuffer,j,k) != 0)
{
result.Append(tempBuffer);
t = result.ToString();
richTextBox1.AppendText(t);
richTextBox1.AppendText("-");
}
//Clear tempbuffer first here
// Then read another two bytes
if (sr.Read(tempBuffer,0,2) != 0)
{
result.Append(tempBuffer);
t = result.ToString();
richTextBox1.AppendText(t);
richTextBox1.AppendText("-");
}
for( int i = 0; i < tempBuffer.Length; i++ )
tempBuffer[i] = (char)0;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO;
using System.Text;namespace WindowsApplication5
{
/// <summary>
/// LoadForecastData 的摘要说明。
/// </summary>
public class LoadForecastDataForm : System.Windows.Forms.Form
{
private System.Windows.Forms.RichTextBox richTextBox1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null; public LoadForecastDataForm()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.SuspendLayout();
//
// richTextBox1
//
this.richTextBox1.Location = new System.Drawing.Point(32, 32);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(464, 416);
this.richTextBox1.TabIndex = 0;
this.richTextBox1.Text = "";
//
// LoadForecastDataForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(976, 470);
this.Controls.Add(this.richTextBox1);
this.Name = "LoadForecastDataForm";
this.Text = "LoadForecastDataForm";
this.Load += new System.EventHandler(this.LoadForecastDataForm_Load);
this.ResumeLayout(false); }
#endregion private void LoadForecastDataForm_Load(object sender,System.EventArgs e)
{
StreamReader sr = new StreamReader( @"D:\ForecastResult.dat", Encoding.GetEncoding("GB2312") );
char[] tempBuffer=new char[100];
StringBuilder result = new StringBuilder("");
string t;
sr.ReadLine();
sr.ReadLine();
if (sr.Read(tempBuffer,0,4) != 0)
{
result.Append(tempBuffer);
t = result.ToString();
richTextBox1.AppendText(t);
richTextBox1.AppendText("-");
}
for( int i = 0; i < tempBuffer.Length; i++ )
tempBuffer[i] = (char)0;
if (sr.Read(tempBuffer,0,2) != 0)
{
result.Append(tempBuffer);
t = result.ToString();
richTextBox1.AppendText(t);
richTextBox1.AppendText("-");
}
sr.Close();
}
}
}
本次预测执行时间:2005-7-10 9:10:23
时间 实际值 择优结果 Schema003 Schema005 Schema006
200505100000 1063.43 1041.97 0 1037.46 1041.97
200505100005 1004.45 1041.98 0 1031.3 1041.98
200505100010 1018.14 1045.53 0 1038.46 1045.53
200505100015 1036.73 1039.45 0 1044.16 1039.45
200505100020 1036.45 1031.82 0 1049.39 1031.82
200505100025 1039.63 1024.41 0 1046.9 1024.41
200505100030 1045.05 1014.66 0 1038.8 1014.66
200505100035 1052.95 1033.77 0 1038.94 1033.77
200505100040 1056.20 1015.57 0 1029.06 1015.57
200505100045 1068.58 1021.50 0 1023.53 1021.50
200505100050 1038.08 1028.13 0 1038.11 1028.13
200505100055 1020.30 1036.50 0 1035.48 1036.50
200505100100 1056.71 1036.84 0 1034.15 1036.84
200505100105 1039.39 1043.42 0 1037.72 1043.42
200505100110 1033.99 1038.88 0 1032 1038.88
200505100115 1046.46 1037.37 0 1034.99 1037.37
200505100120 1068.73 1029.64 0 1033.42 1029.64
200505100125 1071.75 1047.93 0 1033.98 1047.93
200505100130 1057.33 1042.39 0 1042.28 1042.39
200505100135 1009.12 1045.58 0 1046.72 1045.58
200505100140 1091.63 1039.25 0 1034.02 1039.25
200505100145 1098.38 1033.82 0 1030.27 1033.82
200505100150 1106.51 1042.09 0 1042.83 1042.09
200505100155 1089.34 1041.03 0 1042.61 1041.03
200505100200 1075.48 1032.43 0 1036.09 1032.43