0
我有一個包含多個查詢的SQL文件。由於它是一個SQL文件,因此它具有用分號(;)分隔的查詢。我想讀取SQL文件並將查詢作爲Scala中的Array[String]
。將文件的內容分割爲Scala中的Array [String]
例如,我有queries.sql
文件,其中包含類的查詢:
select * from table1;
select col1,col2,col3 from table1 where col1 = ''
col2 = '';
select count(*) from table;
我所要的輸出是這樣的:
Array("select * from table1","select col1,col2,col3 from table1 where col1 = '' col2 =' '","select count(*) from table")
你必須用'「yourfile.sql」' – meucaa
'替換''謝謝你,超級快:),它給了我想要的東西。謝謝 –
user1105412