Replacing text in a file using java

前端 未结 1 1180
不知归路
不知归路 2021-01-28 10:49

I have a text file named FormatString.java. It contains a few words. OUt of those words, I want to replace the word oldstring with newstring and rename the final result as t.txt

1条回答
  •  北恋
    北恋 (楼主)
    2021-01-28 11:49

    If you are running the program from command line, maybe you wan to put the FormatString.java in your bin folder.

    With Eclipse

    ProjectRootFolder
                   bin
                      FromatString.java
                      ReplacingText.class
    
                   src
                      ReplacingText.java
    

    With Netbeans

    ProjectRootFolder
                   build
                       classes
                            FromatString.txt
    
                            replacinttext
                                    ReplacingText.class
    
                   src
                      ReplacingText.java
    

    C:\Users\Dhaval\Desktop\Java Assignment\ReplacingText\build\classes>java replacingtext.ReplaceText FormatString.java public private

    Try to run the program like I have above with all the files in the same Directorys like I have

    0 讨论(0)
提交回复
热议问题