Java junior programmers and ChatGPT (Wen Xin Yi Yan) experience

Foreword:

        With the rapid development of ChatGPT at the beginning of March 23, it became popular on the Internet. There are also many people who say that this thing will replace programmers. It just so happens that a colleague around me has a need to read the content in the word document and save it to the database.

        Let's use Baidu's Wenxin Yiyan to try it out.

Interaction begins:

 

         Generally speaking, the feedback from question to question is relatively smooth. The copy button is also thoughtfully given in the code block. The second dependency question is also vague, but it can give an accurate answer. It not only provides maven dependency format, but also provides groovy format dependency.

The code runs:

        Reported an error

        Let's ask why it is wrong:

 

        Initially, it seems to be a format problem. The word file I uploaded here ends with the suffix of the doc file. Ask if there is another code to solve it.

         This time it feels that the answer is a bit out of place, so let's make room for it and replace our file with the docx file suffix.

run again:

 

          This time it worked, but the console only output the first line of text.

Look at the dependent api documents and codes later. Finally finished. The effect is also out.

Code after working on this code:

    public static void main(String[] args) {
        try {
            // 读取word文件
            FileInputStream inputStream = new FileInputStream(new File("C:\\Users\\Administrator\\Desktop\\test2.docx"));
            XWPFDocument document = new XWPFDocument(inputStream);

            // 获取文档中的段落
            
            //字符串拼接
            StringBuffer sb=new StringBuffer();
            //行数控制器,下标为0考试
            
            int size = document.getParagraphs().size();
            System.out.println("总行数:"+size);
            for (int i = 0; i < size; i++) {
                XWPFParagraph paragraph = document.getParagraphs().get(i);
                String text = paragraph.getText();
                sb.append(text+"\n");
            }
            System.out.println(sb);
            // 输出段落内容
//            System.out.println("段落内容:" + paragraph.getText());

            // 关闭文件流
            inputStream.close();
            System.out.println("结束!");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

 Output result:

总行数:2
222是的哇的
的哇大苏打

结束!

Summarize:

        The experience of cooperating with ChatGPT type AI this time is still good. I have no previous experience in interacting with word documents, but I was able to implement the function in a short time.

        Unlike before, no matter in Baidu, csdn, brief description, or developer search, it takes time to identify solutions to problems. The answer or solution given by Wen Xinyiyan is quite accurate.

        In general, chatGPT and similar products will indeed bring a lot of impact to many industries. However, from the perspective of a Java programmer unilaterally, he can indeed bring benefits to the program in terms of work efficiency. But it can't completely replace the programmer, just like reading the word document this time. Although it can point out what technology stack is used, what the code looks like roughly. But programmers have to make adjustments according to business scenarios.

        It may indeed lead to the shrinking of the position of programmers, because the efficiency of using good programmers can be greatly improved. So I personally feel that this development project will be a procedural skill in the future, and it is also an indispensable bonus item on the resume.

Guess you like

Origin blog.csdn.net/m0_58907154/article/details/130059710