Forums Register Login

String array problem

+Pie Number of slices to send: Send
Hello friends the following is a head banging problem i am currently suffering from.. please have a look at it..


Inside the while loop everything works fine.. The text file is opened and saved in the string array and printed..But out side the for,i am trying to print the saved array string, But i am getting only null as the output...

Please solve this issue...
+Pie Number of slices to send: Send
In the second loop you're incrementing variable i, in stead of variable k.

+Pie Number of slices to send: Send
print this out inside your while loop and see what it does:



Hunter
+Pie Number of slices to send: Send
And think about what the value of fileLine[k] is going to be when you exit the while loop.
+Pie Number of slices to send: Send
Your logic is the problem, in the while loop, you assigned the whole Strings from your file including null(End of File) to a single array element fileLine[k]. Correct it. (Finally you assigned null to your fileLine[k] single element, then you check whether that element is null or not - the problem is here. Have a deep look.)
+Pie Number of slices to send: Send
Thank you very much for the replies... I will try the suggestions and post the results back...
He was expelled for perverse baking experiments. This tiny ad is a model student:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 642 times.
Similar Threads
Array vs java.util.ArrayList
need help to read the contents from a text file and store in a list
where am i calling method in wrong ??
While working from Head first java, I came across this problem... Please help
uploading file using ClientHttpRequest2 and FileUploadServlet
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 08:26:42.