C# Java 自動讀取小說章節。

最近有人在帖子留言問如何獲取小說章節,寫篇文章說下吧。

上來先看下效果:

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ZTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            foreach (string str in System.IO.File.ReadAllLines("d:\\xiaoshuo.txt", Encoding.Default))
            {
                //Console.WriteLine(str); // str就是每一行數據
                Print(str);
            }
        }
        private void Print(string str) {
            if (str.Contains("第") && str.Contains("章")) {
                Console.WriteLine(str); //
            }
        }
    }
}

寫到這裏可能有人說這也太簡單了吧,的確。

如果有的需要負責章節讀取的,歡迎留言。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章