Gentlemen
Ulf - many thanks for the suggestion, but I'm afraid it causes the program to fail in both the IDE (Netbeans) and in the .jar. Curiously enough "src/solowarforedadhopponent/resources/MasteryCardData.esd" works just as well in the IDE as "src\\solowarforedadhopponent\\resources\\MasteryCardData.esd". As I said in my last post, I
really don't understand the \\ vs / thing, but I hope it's not key.
Henry - it seems from your tone that you're finding this exchange irritating, for which I apologise, but the reason I'm posting to this forum is that I'm very much a Java beginner despite having joined this forum some years ago. I'm a hobbyist programmer, and I only usually get to programming about once a year, and it usually involves me largely re-learning Java from scratch (I use "Head First Java" mainly because it's fun).
Henry Wong wrote: First of all, why do you absolutely need the readLine() method? Are you saying that you can't parse it, if the BufferedReader class isn't available?
I'm saying I don't know
how to parse it if the BufferedReader class isn't available. I'm sure that there are plenty of other ways of parsing a file I don't know about. During my scouring of the API I found a bunch of bit-wise methods in the getResourceAsStream section, so I know that's
possible to do it bit-wise, but that seems a crazy way to tackle a .csv file; the readLine() method gives me a line at a time as a string which I know how to manipulate satisfactorily.
Essentially I've written some code to parse the .csv file which works fine, and re-writing it to solve what I perceive (albeit probably wrongly) as a path issue looks like tail wagging dog. That said, there are probably more elegant ways of doing this I don't know about as well, however I'm relying on a code segment from the "Head First Java" book, which only mentions this way of handling text files, so it's the only method I know.
Here's the full code section (I was avoiding posting this because it's long but I think the time has come) so you can see what I'm up to:
I've left in all the ideas I've tried and failed with, as comments, to avoid re-treading the same ground; happily it also allows you to see what I've tried too.
Henry Wong wrote:Second, why do you need a FileReader ? Are you saying that you can't get a BufferedReader without a FileReader ?
I'm really not asserting anything. It just appears from the section of the book and the code examples that a BufferedReader takes a FileReader as a constructor argument.
*looks at API*
The API suggests I simply need a Reader of which BufferedReader, CharArrayReader, FilterReader, InputStreamReader, PipedReader, StringReader are all sub-classes. It's interesting that FileReader is not on that list.
However, InputStreamReader looks promising...
I'll try this:
This works inside the IDE fine... but not in the .jar
Okay Simon, don't panic yet. Try "resources/MasteryCardData.esd"
This works inside the IDE fine... AND AS A .jar
Yes! He can be taught!
Many Thanks Henry
p.s. I still don't know why the IDE takes \\ but the jar only likes /?