分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow

也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!

需求分析:

  1. 获得文本名称
  2. 实现尾部追加功能
  3. 实现覆盖式添加数据
  4. 删除数据
  5. 获取光标位置
  6. 在特定光标位置处添加数据
  7. 查找特定字符串在主串中第一次出现的位置
  8. 统计文本文件内出现的数字,汉字,英文字母,特殊字符的个数,及总的字符个数

    开发环境:
    windows7 + Eclipse luna + WindowsBuilder插件

代码实现:

import java.awt.EventQueue;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.io.BufferedReader;import java.io.BufferedWriter;import java.io.File;import java.io.FileOutputStream;import java.io.FileReader;import java.io.IOException;import java.io.OutputStreamWriter;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JTextArea;import javax.swing.border.EmptyBorder;import javax.swing.event.CaretEvent;import javax.swing.event.CaretListener;public class Test extends JFrame {    private JPanel contentPane;    private static File file = null;    static int CursorPosition=-1;    /**     * Launch the application.     */    public static void main(String[] args) {        EventQueue.invokeLater(new Runnable() {            public void run() {                try {                    Test frame = new Test();                    frame.setVisible(true);                } catch (Exception e) {                    e.printStackTrace();                }            }        });    }    /**     * Create the frame.     */    public Test() {        file = new File("F://test.txt");        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);        setBounds(100, 100, 720, 480);        contentPane = new JPanel();        contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));        setContentPane(contentPane);        contentPane.setLayout(null);        JTextArea taShow = new JTextArea();        taShow.setLineWrap(true);        taShow.setBounds(21, 41, 400, 359);        JLabel label = new JLabel("\u6587\u672C\u9884\u89C8\u533A\uFF1A");        label.setBounds(21, 16, 89, 15);        contentPane.add(label);        JTextArea taEdit = new JTextArea();        taEdit.setLineWrap(true);        taEdit.setBounds(449, 41, 233, 131);        contentPane.add(taEdit);        taShow.addCaretListener(new CaretListener() {            @Override            public void caretUpdate(CaretEvent e) {                // TODO Auto-generated method stub                StringBuffer sb = new StringBuffer();                String length = "";                String fileTitle;                String fileContent;                try {                    BufferedReader reader = new BufferedReader(new FileReader(                            "F://test.txt"));                    while ((length = reader.readLine()) != null) {                        sb.append(length);                    }                    fileContent = sb.toString();                    taShow.setText("您打开的文件的内容是:" + fileContent);                    CursorPosition = e.getDot();                } catch (Exception e1) {                    // TODO Auto-generated catch block                    e1.printStackTrace();                }            }        });        contentPane.add(taShow);        JButton btnGetName = new JButton("\u6587\u6863\u540D\u79F0");        btnGetName.setBounds(449, 211, 93, 23);        btnGetName.addActionListener(new ActionListener() {            @Override            public void actionPerformed(ActionEvent e) {                // TODO Auto-generated method stub                StringBuffer sb = new StringBuffer();                String length = "";                String fileTitle;                String fileContent;                try {                    BufferedReader reader = new BufferedReader(new FileReader(                            "F://test.txt"));                    while ((length = reader.readLine()) != null) {                        sb.append(length);                    }                    fileContent = sb.toString();                    fileTitle = file.getName().toString();                    taEdit.setText("您打开的文件的名称是:" + fileTitle);                    taShow.setText("您打开的文件的内容是:" + fileContent);                } catch (Exception e1) {                    // TODO Auto-generated catch block                    e1.printStackTrace();                }            }        });        contentPane.add(btnGetName);        JButton btnAppend = new JButton("\u8FFD\u52A0");        btnAppend.setBounds(449, 261, 93, 23);        btnAppend.addActionListener(new ActionListener() {            @Override            public void actionPerformed(ActionEvent e) {                // TODO Auto-generated method stub                String temp = taEdit.getText().toString();                method1("F://test.txt", temp);                StringBuffer sb = new StringBuffer();                String length = "";                String fileTitle;                String fileContent;                try {                    BufferedReader reader = new BufferedReader(new FileReader(                            "F://test.txt"));                    while ((length = reader.readLine()) != null) {                        sb.append(length);                    }                    fileContent = sb.toString();                    fileTitle = file.getName().toString();                    taEdit.setText("您打开的文件的名称是:" + fileTitle);                    taShow.setText("您打开的文件的内容是:" + fileContent);                } catch (Exception e1) {                    // TODO Auto-generated catch block                    e1.printStackTrace();                }            }        });        contentPane.add(btnAppend);        JButton btnOverride = new JButton("\u8986\u76D6");        btnOverride.addActionListener(new ActionListener() {            @Override            public void actionPerformed(ActionEvent e) {                // TODO Auto-generated method stub                BufferedWriter out = null;                try {                    out = new BufferedWriter(new OutputStreamWriter(                            new FileOutputStream(file)));                    out.write(taEdit.getText().toString());                } catch (Exception ex) {                    ex.printStackTrace();                } finally {                    try {                        if (out != null) {                            out.close();                        }                    } catch (IOException le) {                        le.printStackTrace();                    }                }                StringBuffer sb = new StringBuffer();                String length = "";                String fileTitle;                String fileContent;                try {                    BufferedReader reader = new BufferedReader(new FileReader(                            "F://test.txt"));                    while ((length = reader.readLine()) != null) {                        sb.append(length);                    }                    fileContent = sb.toString();                    fileTitle = file.getName().toString();                    taEdit.setText("您打开的文件的名称是:" + fileTitle);                    taShow.setText("您打开的文件的内容是:" + fileContent);                } catch (Exception e1) {                    // TODO Auto-generated catch block                    e1.printStackTrace();                }            }        });        btnOverride.setBounds(449, 308, 93, 23);        contentPane.add(btnOverride);        JButton btnSearch = new JButton("\u67E5\u627E");        btnSearch.setBounds(449, 357, 93, 23);        btnSearch.addActionListener(new ActionListener() {            @Override            public void actionPerformed(ActionEvent e) {                // TODO Auto-generated method stub                StringBuffer sb = new StringBuffer();                String length = "";                String fileTitle;                String fileContent;                try {                    BufferedReader reader = new BufferedReader(new FileReader(                            "F://test.txt"));                    while ((length = reader.readLine()) != null) {                        sb.append(length);                    }                    fileContent = sb.toString();                    taShow.setText("您打开的文件的内容是:" + fileContent);                    String p = taEdit.getText().toString().trim();                    taShow.setText(fileContent+"\n\n"+"您查找的字符串第一次出现的位置是:"+fileContent.indexOf(p));                } catch (Exception e1) {                    // TODO Auto-generated catch block                    e1.printStackTrace();                }            }        });        contentPane.add(btnSearch);        JButton btnPosition = new JButton("\u5149\u6807\u4F4D\u7F6E");        btnPosition.setBounds(589, 211, 93, 23);        btnPosition.enable(false);        contentPane.add(btnPosition);        JButton btnInsert = new JButton("\u5B9A\u70B9\u63D2\u5165");        btnInsert.setBounds(589, 261, 93, 23);        btnInsert.addActionListener(new ActionListener(){            @Override            public void actionPerformed(ActionEvent e) {                // TODO Auto-generated method stub                StringBuffer sb = new StringBuffer();                String length = "";                String fileTitle;                String fileContent;                try {                    BufferedReader reader = new BufferedReader(new FileReader(                            "F://test.txt"));                    while ((length = reader.readLine()) != null) {                        sb.append(length);                    }                    String temp=taEdit.getText().toString();                    sb.insert(CursorPosition, temp);                    method1("F://test.txt", sb.toString());                    taShow.setText(sb.toString());                    taEdit.setText("定点的数据插入成功执行!");                }catch(Exception ev){                    ev.printStackTrace();                }            }        });        contentPane.add(btnInsert);        JButton btnDelete = new JButton("\u5220\u9664");        btnDelete.setBounds(589, 308, 93, 23);        btnDelete.addActionListener(new ActionListener() {            @Override            public void actionPerformed(ActionEvent e) {                // TODO Auto-generated method stub                BufferedWriter out = null;                try {                    out = new BufferedWriter(new OutputStreamWriter(                            new FileOutputStream(file)));                    out.write("");                    taShow.setText("删除操作已完成,请到相应路径下查看!");                } catch (Exception ex) {                    ex.printStackTrace();                } finally {                    try {                        if (out != null) {                            out.close();                        }                    } catch (IOException le) {                        le.printStackTrace();                    }                }            }        });        contentPane.add(btnDelete);        JButton btnTotal = new JButton("\u7EDF\u8BA1");        btnTotal.setBounds(589, 357, 93, 23);        btnTotal.addActionListener(new ActionListener() {            @Override            public void actionPerformed(ActionEvent e) {                // TODO Auto-generated method stub                StringBuffer sb = new StringBuffer();                String length = "";                String fileTitle;                String fileContent;                try {                    BufferedReader reader = new BufferedReader(new FileReader(                            "F://test.txt"));                    while ((length = reader.readLine()) != null) {                        sb.append(length);                    }                    fileContent = sb.toString();                    new Total().find(fileContent);                    String flag = "数据信息统计结果如下:" + "\n" + "汉字数目:";                    flag += new Total().chineseCount;                    flag += "\n英文字母个数:";                    flag += new Total().englishCount;                    flag += "\n特殊字符个数:";                    flag += new Total().numberCount;                    flag += "\n总的字符个数为:"                            + (new Total().chineseCount                                    + new Total().englishCount + new Total().numberCount);                    taShow.setText(flag);                    new Total().chineseCount = 0;                    new Total().englishCount = 0;                    new Total().numberCount = 0;                } catch (Exception ec) {                    ec.printStackTrace();                }            }        });        contentPane.add(btnTotal);        JLabel label_1 = new JLabel("\u6587\u672C\u7F16\u8F91\u533A\uFF1A");        label_1.setBounds(449, 16, 93, 15);        contentPane.add(label_1);    }    public static void method1(String file, String conent) {        BufferedWriter out = null;        try {            out = new BufferedWriter(new OutputStreamWriter(                    new FileOutputStream(file, true)));            out.write(conent);        } catch (Exception e) {            e.printStackTrace();        } finally {            try {                if (out != null) {                    out.close();                }            } catch (IOException e) {                e.printStackTrace();            }        }    }}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307
  • 308
  • 309
  • 310
  • 311
  • 312
  • 313
  • 314
  • 315
  • 316
  • 317
  • 318
  • 319
  • 320
  • 321
  • 322
  • 323
  • 324
  • 325
  • 326
  • 327
  • 328
  • 329
  • 330
  • 331
  • 332
  • 333
  • 334
  • 335
  • 336
  • 337
  • 338
  • 339
  • 340
  • 341
  • 342
  • 343
  • 344
  • 345
  • 346
  • 347
  • 348
  • 349
  • 350
  • 351
  • 352
  • 353
  • 354
  • 355
  • 356
  • 357
  • 358
  • 359
  • 360
  • 361
  • 362
  • 363
  • 364
  • 365
  • 366
  • 367
  • 368
  • 369
  • 370
  • 371
  • 372

下面解释一下为什么没有做好注释合作说明文档,因为我做注释做到一半的时候,出现了一点事故,导致没有来得及保存的文件丢失了,所以,请大家谨记,时刻记得保存编辑的被容,否则后果真的很严重。

代码追补解释,下面的代码块是我程序里面做的不好的,违背了代码的复用性原则,请予以为戒:

代码块1:

//代码的作用就是实现对特定的文件进行读取,并存入到String中,方便使用StringBuffer sb = new StringBuffer();                String length = "";                String fileTitle;                String fileContent;                try {                    BufferedReader reader = new BufferedReader(new FileReader(                            "F://test.txt"));                    while ((length = reader.readLine()) != null) {                        sb.append(length);                    }                    fileContent = sb.toString();                    taShow.setText("您打开的文件的内容是:" + fileContent);                    CursorPosition = e.getDot();                } catch (Exception e1) {                    // TODO Auto-generated catch block                    e1.printStackTrace();                }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19

代码块2:

//代码实现了向特定的文件内追加数据,若想要覆盖式追加,把参数true去掉即可,默认为覆盖式添加数据public static void method1(String file, String conent) {        BufferedWriter out = null;        try {            out = new BufferedWriter(new OutputStreamWriter(                    new FileOutputStream(file, true)));            out.write(conent);        } catch (Exception e) {            e.printStackTrace();        } finally {            try {                if (out != null) {                    out.close();                }            } catch (IOException e) {                e.printStackTrace();            }        }    }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19

代码块3:
在统计模块中:

btnTotal.addActionListener(new ActionListener() {            @Override            public void actionPerformed(ActionEvent e) {                // TODO Auto-generated method stub                StringBuffer sb = new StringBuffer();                String length = "";                String fileTitle;                String fileContent;                try {                    BufferedReader reader = new BufferedReader(new FileReader(                            "F://test.txt"));                    while ((length = reader.readLine()) != null) {                        sb.append(length);                    }                    fileContent = sb.toString();                    new Total().find(fileContent);                    String flag = "数据信息统计结果如下:" + "\n" + "汉字数目:";                    flag += new Total().chineseCount;                    flag += "\n英文字母个数:";                    flag += new Total().englishCount;                    flag += "\n特殊字符个数:";                    flag += new Total().numberCount;                    flag += "\n总的字符个数为:"                            + (new Total().chineseCount                                    + new Total().englishCount + new Total().numberCount);                    taShow.setText(flag);                    new Total().chineseCount = 0;                    new Total().englishCount = 0;                    new Total().numberCount = 0;                } catch (Exception ec) {                    ec.printStackTrace();                }            }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35

其中使用到的new Total().find()方法,详见下面的代码:

package Editer;/** * 分别统计出其中字符串中汉字,英文字母,数字,其他字符数量 * @author wWX154783 *  */public class Total{    static String E1,E2,E3;    String str="a12中国3@b&4语*言3c";    static int chineseCount = 0;    static int englishCount = 0;    static int numberCount = 0;    public void find(String str)    {        String E1 = "[\u4e00-\u9fa5]";// 中文        String E2 = "[a-zA-Z]";// 英文        String E3 = "[0-9]";// 数字        String temp;        for (int i = 0; i < str.length(); i++)        {            temp = String.valueOf(str.charAt(i));            if (temp.matches(E1))            {                chineseCount++;            }            if (temp.matches(E2))            {                englishCount++;            }            if (temp.matches(E3))            {                numberCount++;            }        }        System.out.println("汉字数:" + chineseCount);        System.out.println("英文数:" + englishCount);        System.out.println("数字数:" + numberCount);        System.out.println("特殊字符:" + (str.length() - (chineseCount + englishCount + numberCount)));    }}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48

好了,下面是程序运行后得到的界面,在此我要声明的是,程序仍然存在一些bug,表现在获得光标位置时的java.lang.IllegalStateException: Attempt to mutate in notification异常,主要还是线程相关,如果博友能解决,还望不吝赐教




能力有限,希望和大家一起进步,一同提高!

接下来的是我从网上找到的一份用C语言实现的简易的文本编辑器的实现,个人认为较之,我的简直就是太菜了,现在将代码贴出来,希望这篇C语言的经典能让更多的人知晓:

#include <stdio.h>#define MAXLEN 80#define MAXLINE 200char buffer[MAXLEN],fname[120];char *lineptr[MAXLINE];FILE *fp;void edit(),replace(),insert(),delete(),quit();char comch[]="EeRrIiDdQq";/*命令符*/void(*comfun[])()={edit,replace,insert,delete,quit};/*对应处理函数*/int modified=0,/*正文被修改标志*/    last;/*当前正文行数*/char *chpt;/*输入命令行字符指针*/main(){    int j;    last=0;    while(1)    {        printf("\nInput a command:[e,r,i,d,q].\n");        gets(buffer);/*读入命令行*/        for(chpt=buffer;*chpt=='\0'||*chpt=='\t';chpt++);/*掠过空白符*/        if(*chpt=='\0') continue;/*空行重新输入*/        for(j=0;comch[j]!='\0'&&comch[j]!=*chpt;j++);/*查命令符*/        if(comch[j]=='\0') continue;/*非法命令符*/        chpt++;/*掠过命令符,指向参数*/        (*comfun[j/2])();/*执行对应函数*/        fprintf(stdout,"The text is:\n");        for(j=0;j<last;j++)/*显示正文*/            fputs(lineptr[j],stdout);    }}void quit(){    int c;    if(modified)/* 如正文被修改 */    {        printf("Save? (y/n)");        while(!(((c=getchar())>='a'&&c<='z')||(c>='A'&&c<='Z')));        if(c=='y'||c=='Y')            save(fname); /* 保存被修改过的正文 */    }    for(c=0;c<last;c++)        free(lineptr[c]);   /* 释放内存 */    exit(0);}void insert(){    int k,m,i;    sscanf(chpt,"%d%d",&k,&m);  /* 读入参数 */    if(m<0||m>last||last+k>=MAXLINE)/* 检查参数合理性 */    {        printf("Error!\n");        return;    }    for(i=last;i>m;i--)/* 后继行向后移 */        lineptr[i+k-1]=lineptr[i-1];    for(i=0;i<k;i++)   /* 读入k行正文,并插入 */    {        fgets(buffer,MAXLEN,stdin);        lineptr[m+i]=(char *)malloc(strlen(buffer)+1);        strcpy(lineptr[m+i],buffer);    }    last+=k;    /* 修正正文行数 */    modified=1; /* 正文被修改 */}void delete(){    int i,j,m,n;    sscanf(chpt,"%d%d",&m,&n);  /* 读入参数 */    if(m<=0||m>last||n<m)   /* 检查参数合理性 */    {        printf("Error!\n");        return;    }    if(n>last)        n=last;     /* 修正参数 */    for(i=m;i<=n;i++)   /* 删除正文 */        free(lineptr[i-1]);    for(i=m,j=n+1;j<=last;i++,j++)        lineptr[i-1]=lineptr[j-1];    last=i-1;   /* 修正正文行数 */    modified=1; /* 正文被修改 */}void replace(){    int k,m,n,i,j;    sscanf(chpt,"%d%d%d",&k,&m,&n); /* 读入参数 */    if(m<=0||m>last||n<m||last-(n-m+1)+k>=MAXLINE)/* 检查参数合理性 */    {        printf("Error!\n");        return;    }    /* 先完成删除 */    if(n>last)        n=last;     /* 修正参数 */    for(i=m;i<=n;i++)   /* 删除正文 */        free(lineptr[i-1]);    for(i=m,j=n+1;j<=last;i++,j++)        lineptr[i-1]=lineptr[j-1];    last=i-1;    /* 以下完成插入 */    for(i=last;i>=m;i--)        lineptr[i+k-1]=lineptr[i-1];    for(i=0;i<k;i++)    {        fgets(buffer,MAXLEN,stdin);        lineptr[m+i-1]=(char *)malloc(strlen(buffer)+1);        strcpy(lineptr[m+i-1],buffer);    }    last+=k;    /* 修正正文行数 */    modified=1; /* 正文被修改 */}save(char *fname)   /* 保存文件 */{    int i;    FILE *fp;    if((fp=fopen(fname,"w"))==NULL)    {        fprintf(stderr,"Can't open %s.\n",fname);        exit(1);    }    for(i=0;i<last;i++)    {        fputs(lineptr[i],fp);        free(lineptr[i]);    }    fclose(fp);}void edit() /* 编辑命令 */{    int i;    FILE *fp;    i=sscanf(chpt,"%s",fname);  /* 读入文件名 */    if(i!=1)    {        printf("Enter file name.\n");        scanf("%s",fname);    }    if((fp=fopen(fname,"r"))==NULL) /* 读打开 */    {        fp=fopen(fname,"w");    /* 如不存在,则创建文件 */        fclose(fp);        fp=fopen(fname,"r");    /* 重新读打开 */    }    i=0;    while(fgets(buffer,MAXLEN,fp)==buffer)    {        lineptr[i]=(char *)malloc(strlen(buffer)+1);        strcpy(lineptr[i++],buffer);    }    fclose(fp);    last=i;}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161

给我老师的人工智能教程打call!http://blog.csdn.net/jiangjunshow

Java实现简易的文本编辑器相关推荐

  1. 用C++实现简易的文本编辑器

    终于开始准备写自己的第一篇博客了,想想现在大二结束了,也要开始准备整理这么久学习的知识.学长们都对我说写博客是对自己知识整理最好的方法,所以我就静下心来把自己的课设写成自己的第一篇博客吧. 废话就不多 ...

  2. java实现在线富文本编辑器,并传格式数据给后端

    做了一个简易在线的富文本编辑器,前端是html,后台是Java 前端代码: <html lang="en" xmlns:th="http://www.thymele ...

  3. kindeditor java ssm_easyUI整合富文本编辑器KindEditor详细教程(附源码)

    原因 在今年4月份的时候写过一篇关于easyui整合UEditor的文章Spring+SpringMVC+MyBatis+easyUI整合优化篇(六)easyUI与富文本编辑器UEditor整合,从那 ...

  4. [汇编] 汇编语言实现简易文本编辑器(光标移动、上卷和退格删除)

    https://blog.csdn.net/NK_test/article/details/46045201 汇编实现的一个简易的文本编辑器,代码中有详细的注释. 思路和细节: (1) 在屏幕中央初始 ...

  5. [转][汇编] 汇编语言实现简易文本编辑器(光标移动、上卷和退格删除)

    汇编实现的一个简易的文本编辑器,代码中有详细的注释. 思路和细节: (1) 在屏幕中央初始化一片面积,并且定位光标,利用16号中断0号功能分别在ah,al中存储扫描码和ascii码,由此进行功能键的判 ...

  6. kind富文本编辑器_富文本编辑器原理探索

    经常在做企业网站的管理系统的时候需要用到富文本编辑器,之前基本上都是直接去 npm 或者 github 上面搜找一些排名考前或者 readme 写的好的库,直接拿来用.万变不离其宗,是时候探索下本质了 ...

  7. 10款著名的代码(文本)编辑器

    下面是笔者总结的 10 个最好的免费代码文本编辑器: 1. NOTEPAD++ NOTEPAD++是一款免费又优秀的文本编辑器,支持在 MS Windows 环境下运行的多种编程语言.NOTEPAD+ ...

  8. 列模式 文本编辑器_UltraEdit 24.2 文本编辑器免费版

    UltraEdit是由IDM官方最新出品的文本编辑器版本,它是一款性价比全球一流的文本.十六进制,HTML.PHP.Java 和 JavaScript程序文本编辑器,被认为是世界上最好的文本编辑器.U ...

  9. android 富文本编辑器_富文本编辑器原理探索

    经常在做企业网站的管理系统的时候需要用到富文本编辑器,之前基本上都是直接去 npm 或者 github 上面搜找一些排名考前或者 readme 写的好的库,直接拿来用.万变不离其宗,是时候探索下本质了 ...

  10. 10款最著名的代码(文本)编辑器

    通常操作系统和软件开发包中都包含文本编辑器,可以用来编辑配置文件,文档文件和源代码. 下面是笔者总结的 10 个最好的免费代码文本编辑器: 1. NOTEPAD++ NOTEPAD++是一款免费又优秀 ...

最新文章

  1. 穿了个GUI马甲的PyInstaller
  2. linux FTP配置详解
  3. jquery实现抽奖系统
  4. 第四届程序设计竞赛(天梯赛)华南赛区回顾
  5. android 一个很漂亮的控件ObservableScrollView(含片段代码和源码)
  6. 基于Socket的java网络编程
  7. 简陋版C语言仿真通讯录
  8. 如何系统地自学前端(女生),女生发展前端是否是青春饭?
  9. java 在类中定义接口_我们可以在Java接口中定义一个类吗?
  10. NIS 病毒库 更新 地址
  11. 新经济 DTC 转型,一个简单而强大的数据平台至关重要
  12. x509证书、openssl、go生成证书
  13. 在Vmware 14 pro 中安装中兴新支点操作系统
  14. 记录学习历程-----游戏编程
  15. 出现Ncat: bind to 0.0.0.0:9999: Address already in use. QUITTING.如何解决?
  16. Codeforces Round #645 (Div. 2)
  17. Ubuntu 配置亚马逊 aws cli 上传文件文件夹至 亚马逊 AWS S3
  18. OWASP的s-sdlc项目优秀分享
  19. 基于独立工作流引擎实现的SuperFlow工作流平台设计方案
  20. 基于attention机制的中英文机器翻译

热门文章

  1. python爬虫定时运行_python 爬虫 定时计划任务
  2. 楚留香ai识别人脸_【专利解密】商汤科技:AI加持人脸识别
  3. 动态规划实战13 leetcode-121. Best Time to Buy and Sell Stock
  4. Springboot的工作机制:1 Springboot初体验
  5. Java基础(四):异常处理
  6. linux web部署命令简单记录
  7. APP被苹果App Store拒绝的79个原因【转】
  8. HDU 5634 Rikka with Phi
  9. Android串口示波器,解读一个超赞的开源串口虚拟示波器项目
  10. 最小割最大流算法matlab,matlab练习程序(最大流/最小割)