Why is createNewFile being called inside of the loop? Why is it trying to create the input file?
What is in oq.txt when the program finishes?
What is shown on the console when the program is executed?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Why is createNewFile being called inside of the loop? Why is it trying to create the input file?
What is in oq.txt when the program finishes?
What is shown on the console when the program is executed?
If you don't understand my answer, don't ignore it, ask a question.
cnmeysam (March 21st, 2021)
To write values line by line
The basic data is in it oq.txt
All data retrieved from the original file will be displayed in the console after editing ( The same data that is stored in the new file )
I do not understand, except for the part related to space, the program works properly. what is the problem?
Please copy what is printed on the console and paste it here.
Why is createNewFile being called inside of the loop?
Is there other code that reads/writes the output file? I don't see any statements that would remove the space.
The code does not remove a space for me.
If you don't understand my answer, don't ignore it, ask a question.
cnmeysam (March 21st, 2021)
not any code just this isrun: File already exists. File already exists. File already exists. File already exists. File already exists. <AzanID="1"> <Day>Sunday</Day> <date>1400/01/01</date> <morning>04:43:02</morning> <Sunrise>06:06:49</Sunrise> <Noon>12:12:09</Noon> <sunset>18:17:30</sunset> <evening>18:35:33</evening> <midnight>23:30:16</midnight> </Azan> File already exists. <AzanID="2"> <Day>Monday</Day> <date>1400/01/02</date> <morning>05:41:30</morning> <Sunrise>07:05:23</Sunrise> <Noon>13:11:51</Noon> <sunset>19:18:20</sunset> <evening>19:36:23</evening> <midnight>00:29:55</midnight> </Azan> File already exists.
must be<AzanID="1"> <AzanID="2">
like original file<Azan ID="1"> <Azan ID="2">
Why is createNewFile being called inside of the loop? where i must write that?
--- Update ---
in the oq.txt file is:
<Azan ID="1"> <Day>Sunday</Day> <date>1400/01/01</date> <morning>04:43:02 <Sunrise>06:06:49 <Noon>12:12:09 <sunset>18:17:30 <evening>18:35:33 <midnight>23:30:16 </Azan> <Azan ID="2"> <Day>Monday</Day> <date>1400/01/02</date> <morning>05:41:30 <Sunrise>07:05:23 <Noon>13:11:51 <sunset>19:18:20 <evening>19:36:23 <midnight>00:29:55 </Azan>
in new file
<AzanID="1"> <Day>Sunday</Day> <date>1400/01/01</date> <morning>04:43:02</morning> <Sunrise>06:06:49</Sunrise> <Noon>12:12:09</Noon> <sunset>18:17:30</sunset> <evening>18:35:33</evening> <midnight>23:30:16</midnight> </Azan> <AzanID="2"> <Day>Monday</Day> <date>1400/01/02</date> <morning>05:41:30</morning> <Sunrise>07:05:23</Sunrise> <Noon>13:11:51</Noon> <sunset>19:18:20</sunset> <evening>19:36:23</evening> <midnight>00:29:55</midnight> </Azan>
--- Update ---
i think
Cannot recognize space. because when before or after a word is placed space, it does not read spacemyStr.startsWith
Last edited by cnmeysam; March 21st, 2021 at 04:37 PM.
I copied the contents of the oq.txt file that was posted and saved it on my PC.
When I run the posted code I get this in the testFile1.txt:There is a space before the ID=<Azan ID="1">
<Day>Sunday</Day>
<morning>04:43:02</morning>
<Sunrise>06:06:49</Sunrise>
<Noon>12:12:09</Noon>
<sunset>18:17:30</sunset>
<evening>18:35:33</evening>
<midnight>23:30:16</midnight>
</Azan>
<Azan ID="2">
<Day>Monday</Day>
<morning>05:41:30</morning>
<Sunrise>07:05:23</Sunrise>
<Noon>13:11:51</Noon>
<sunset>19:18:20</sunset>
<evening>19:36:23</evening>
<midnight>00:29:55</midnight>
</Azan>
Also Notice there is NOT a blank line between </Azan> and <Azan ID="2">
Also this line is NOT in the new file: <date>1400/01/01</date>
I do not understand how what you say is in new file came from the posted code.
There must be a different program being used to create the new file.
If you don't understand my answer, don't ignore it, ask a question.
cnmeysam (March 21st, 2021)
you cant see <date>1400/01/01</date> because date must be Date
i can't understand in my project Why remove space before ID
--- Update ---
I'm very, very sorry I was wrong. The original file had a problem
Is your problem solved now?
If you don't understand my answer, don't ignore it, ask a question.
cnmeysam (March 21st, 2021)
ok thank my problem solved now