Blogger

Delete comment from: Stephen Colebourne's blog

here's a use-case: Suppose you want to pass source code from Java to another compiler. e.g .SQL. Suppose I define a simple table:

create table foo (
bar int
,fum varchar(200)
);

Now, I can paste that into some SQL IDE and run it more or less as is. If I were passing it to the DBMS via Java, I'd like to do something like this:

String ddl =
create table foo (
bar int
,fum varchar(200)
);


then I can pass the ddl in a call to the DBMS. This way, I have the same alternate-language source in Java and my favorite DB IDE. Same spacing and newlines. The only thing I'd want Java to do in addition is provide a way to strip the common leading spaces (four, in this case). That's not important for SQL of course, but could be in other, indentation-sensitive languages (Python, e.g.)


Oct 28, 2013, 10:04:54 AM


Posted to Java 7 - Multi-line String literals

Google apps
Main menu