I am storing sql in a properties file and injecting it using spring this works :
someSQL = select result from myTable where y = 2 and x = ? order by z
but for readibility I want this :
someSQL = select result from myTable where y = 2 and x = ? order by z
What is the correct text formatting I need to use ?
You add a slash ("\") to continue the value on the next line.
Java Read File line by line using BufferedReader We can use java. io. BufferedReader readLine() method to read file line by line to String. This method returns null when end of file is reached.
So you can create two applications. properties files one for the original database and the other for the test database which you use during development.
Use \ at the end of the line like
someSQL = select result \ from myTable \ where y = 2 \ and x = ? \ order by z
Also, beware of any trailing whitespaces since Java looks for consecutive backslash+linebreak when assembling the lines.
Put differently : The backslash has to be the very last caracter on the line before the line break.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With