could someone explain me this line of code:

           public void createTextFile(Layer layer, String prcString, String arString) {
           File fileStatPercent = new File(fileName+layer.getName() + "Test.txt");
           try {
           BufferedWriter out = new BufferedWriter(new FileWriter(fileName + layer.getName() + "Test.txt"));


Thank you, i don't understand


Recommended Answers

All 4 Replies

Sorry for this question, but my question is why we use Layer here.
of course i understqnd this code is writing data in file Text.txt but what is Layer?

I don't understand the third line of my code.

Thank you

You would have to discuss the matter with the original coder to get a definitive answer, actually. It really has nothing to do with the BufferedReader c'tor itself, which just takes a filename as it's argument.

As for line 3, that's the beginning of an exception frame. You would need to read up on exceptions to understand the purpose of it, but let's sake for now that the try block is supposed to contain code that might have a runtime error in it; the try says that it will try to run the code, but if it throws an exception, it will halt and go to the catch statement that matches the type of exception that was raised. Exceptions are a bit tricky to understand, so if that didn't make much sense, the best thing is to wait until you've gotten further in studying the language.

THank you Schol-R-LEA for the exception i understand but i have to see the Layer in java
Thank you

We don't know what a Layer is here, but it obviously has a name field that's accessed via its getName method. That's used as part of the file name, ie the file name is made up of three parts:
whatever is in the variable fileName, followed by
whatever the layer.getName() method returns, followed by

So depending on what the getName returns you have a different file for each layer.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.