从txt文件创建多个txt文件

时间:2016-06-23 14:27:34

标签: java arrays text-files readfile

我有一个txt文件,如:

ABC

ABC/DEF

    dxcxvcnsaapd - xxxxxxxxxxxxxxxxxxxxxxxxxxx
ABC/DEF/:7300000

    zxccdnsavcbapd - xxxxxxxxxxxxxxxxxxxxxxxxxxx
ABC/DEF/:2BC0000

    dvcbvbvnsaapd - xxxxxxxxxxxxxxxxxxxxxxxxxxx
ABC/DEF/XYZ

    dnsavccbnbapd - xxxxxxxxxxxxxxxxxxxxxxxxxxx
Test

    dnsavccbnbapd - xxxxxxxxxxxxxxxxxxxxxxxxxxx
    dnsavccbnbapd - xxxxxxxxxxxxxxxxxxxxxxxxxxx
    dnsavccbnbapd - xxxxxxxxxxxxxxxxxxxxxxxxxxx
    dnsavccbnbapd - xxxxxxxxxxxxxxxxxxxxxxxxxxx

Test/abcd

    dnsavccbnbapd - xxxxxxxxxxxxxxxxxxxxxxxxxxx
    dnsavccbnbapd - xxxxxxxxxxxxxxxxxxxxxxxxxxx
    dnsavccbnbapd - xxxxxxxxxxxxxxxxxxxxxxxxxxx
    dnsavccbnbapd - xxxxxxxxxxxxxxxxxxxxxxxxxxx

Test22

    dnsavccbnbapd - xxxxxxxxxxxxxxxxxxxxxxxxxxx
    dnsavccbnbapd - xxxxxxxxxxxxxxxxxxxxxxxxxxx
    dnsavccbnbapd - xxxxxxxxxxxxxxxxxxxxxxxxxxx
    dnsavccbnbapd - xxxxxxxxxxxxxxxxxxxxxxxxxxx

我想创建标题为 ABC,Test,Test22 的txt文件,并用Java编写下面的行。我的意思是例如我需要一个txt。文件标题为 ABC ,我想在其中写下以下几行。

ABC

ABC/DEF

    dxcxvcnsaapd - xxxxxxxxxxxxxxxxxxxxxxxxxxx
ABC/DEF/:7300000

    zxccdnsavcbapd - xxxxxxxxxxxxxxxxxxxxxxxxxxx
ABC/DEF/:2BC0000

    dvcbvbvnsaapd - xxxxxxxxxxxxxxxxxxxxxxxxxxx
ABC/DEF/XYZ

    dnsavccbnbapd - xxxxxxxxxxxxxxxxxxxxxxxxxxx

请您就如何提出解决方案向我提出建议?提前谢谢。

1 个答案:

答案 0 :(得分:0)

按照这些步骤进行反复试验。你将能够解决你的问题。

1 Reading a plain text file in Java

2 How do I create a file and write to it in Java?