2

Java has some specification that states:

Some tools work better when files end with an empty line.

By researching, I have found that it refers only to text files.

What about XML files? Do they need a new line at the end?

  • When I add in Android Studio some vector asset, in that XML file a new line is automatically added at the end.

  • However when creating a new layout file there is no new line at the end of the file.

Henry Twist
  • 5,666
  • 3
  • 19
  • 44
anatoli
  • 1,663
  • 1
  • 17
  • 43
  • Have you read [this answer](https://stackoverflow.com/q/729692/10082297)? It doesn't address Android specifically but I think it covers enough to infer. – Henry Twist Apr 13 '21 at 09:58
  • Also I would like to mention that as far as I'm aware *Java* doesn't have any such *specification*. The link you provided is from a separate entity. – Henry Twist Apr 13 '21 at 10:01
  • Hey @HenryTwist, yes i have read it. And when go throught answers in that topic, then it could be find, that [C++ has a warning](https://stackoverflow.com/questions/72271/no-newline-at-end-of-file-compiler-warning) if no empty line is on the end. Java is inspired from C++ and has similar syntax. All java files have new line on EOF per default. So this answer for `xml` files is not clear enought to be sure. – anatoli Apr 13 '21 at 10:41

0 Answers0