每个文档(inputStream IS)都有一个名为生效日期的字段。我需要将所有这些单独的文档合并为一个按生效日期排序的文档。
import java.util.Properties;
import java.io.InputStream;
for( int i = 0; i < dataContext.getDataCount(); i++ ) {
InputStream is = dataContext.getStream(i);
Properties props = dataContext.getProperties(i);
dataContext.storeStream(is, props);
}
由于 纳格
答案 0 :(得分:0)
将您的文档添加到 private void Form1_Options_Load(object sender, EventArgs e)
{
String connectionString;
connectionString = ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString;
conn = new SqlConnection(connectionString);
String Sequel = "SELECT id,ProductName,ModelType FROM Product";
SqlDataAdapter da = new SqlDataAdapter(Sequel, conn);
DataTable dt = new DataTable();
conn.Open();
da.Fill(dt);
foreach (DataRow dr in dt.Rows)
{
parentNode = treeView1.Nodes.Add(dr["ProductName"].ToString());
//treeView1.Nodes.Add(dr["ModelType"].ToString());
PopulateTreeView(Convert.ToInt32(dr["Id"].ToString()), parentNode);
}
}
public void PopulateTreeView(int parentId, TreeNode parentNode)
{
String Seqchildc = "Select * From Model WHERE ProductId = "+ parentId + "";
SqlDataAdapter dachildmnuc = new SqlDataAdapter(Seqchildc, conn);
DataTable dtchildc = new DataTable();
dachildmnuc.Fill(dtchildc);
TreeNode childNode;
foreach (DataRow dr in dtchildc.Rows)
{
if (parentNode == null)
childNode = treeView1.Nodes.Add(dr["ModelName"].ToString());
//childNode.Nodes.Add(dr["ModelType"].ToString());
else
childNode = parentNode.Nodes.Add(dr["ModelName"].ToString());
//PopulateTreeView(Convert.ToInt32(dr["Id"].ToString()), childNode);
}
treeView1.ExpandAll();
//Connect();
}
,然后使用ArrayList
和比较日期的比较器。之后,使用for-each循环遍历List.sort(Comparator)
并将文档添加到输出中。