Javaで大きな文字列定数を処理する最適な方法は何ですか?私はむしろ、すべての行の前後に引用符とプラスを入れていないと思いますJavaで大きな文字列定数を処理する
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<QuoteRequest xmlns="https://www.bcponline.co.uk">
<header>
<SourceCode>BN325</SourceCode>
<MessageSource>B2B3</MessageSource>
<Profile>B08A</Profile>
<Password>AP3U86V</Password>
<OperatorID>flightline</OperatorID>
<ShowWebOptions>0</ShowWebOptions>
</header>
<serviceSelection>
<ServiceProviderCode></ServiceProviderCode>
<ProductCode>CarParking</ProductCode>
<IATACode>lgw</IATACode>
</serviceSelection>
<quoteDetails>
<DepartureDate>21-Jun-2005</DepartureDate>
<DepartureTime>07:00</DepartureTime>
<ReturnDate>28-Jun-2005</ReturnDate>
<ReturnTime>07:00</ReturnTime>
<QuoteReference></QuoteReference>
<NoPax>1</NoPax>
</quoteDetails>
<sPostCode></sPostCode>
</QuoteRequest>
</soap:Body>
</soap:Envelope>
:
は私がSOAPのためのテスト・フィクスチャを持っていると私は次の文字列を送信することを想像してみてください。それをファイルに入れると余分なコードとなり、同じファイルにいくつかの文字列を入れるのはやや難しくなります。 XMLにはテキストをエスケープする際に問題があります(私はCDATAの醜さを使わなければなりません)。簡単な方法がありますか?
お勧め: '\ n'sとして改行をエンコードする方法はありますか? –
プロパティファイルに入れることができます。まだコードを書く必要がありますが、それほど多くはないので、複数の文字列を入れることができます – jny
関連:http://stackoverflow.com/questions/782810/working-with-large-text-snippets-in-java-source –