Note that there are some explanatory texts on larger screens.

plurals
  1. POHandling Large String Constants in Java
    primarykey
    data
    text
    <p>What is the best way to handle large string constants in Java?</p> <p>Imagine that I have a test fixture for SOAP and I want to send the following string:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;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/"&gt; &lt;soap:Body&gt; &lt;QuoteRequest xmlns="https://www.bcponline.co.uk"&gt; &lt;header&gt; &lt;SourceCode&gt;BN325&lt;/SourceCode&gt; &lt;MessageSource&gt;B2B3&lt;/MessageSource&gt; &lt;Profile&gt;B08A&lt;/Profile&gt; &lt;Password&gt;AP3U86V&lt;/Password&gt; &lt;OperatorID&gt;flightline&lt;/OperatorID&gt; &lt;ShowWebOptions&gt;0&lt;/ShowWebOptions&gt; &lt;/header&gt; &lt;serviceSelection&gt; &lt;ServiceProviderCode&gt;&lt;/ServiceProviderCode&gt; &lt;ProductCode&gt;CarParking&lt;/ProductCode&gt; &lt;IATACode&gt;lgw&lt;/IATACode&gt; &lt;/serviceSelection&gt; &lt;quoteDetails&gt; &lt;DepartureDate&gt;21-Jun-2005&lt;/DepartureDate&gt; &lt;DepartureTime&gt;07:00&lt;/DepartureTime&gt; &lt;ReturnDate&gt;28-Jun-2005&lt;/ReturnDate&gt; &lt;ReturnTime&gt;07:00&lt;/ReturnTime&gt; &lt;QuoteReference&gt;&lt;/QuoteReference&gt; &lt;NoPax&gt;1&lt;/NoPax&gt; &lt;/quoteDetails&gt; &lt;sPostCode&gt;&lt;/sPostCode&gt; &lt;/QuoteRequest&gt; &lt;/soap:Body&gt; &lt;/soap:Envelope&gt; </code></pre> <p>I'd rather not put quotes and pluses around every line. If I put it in a file it's extra code and it would be somewhat hard to put several strings in the same file. XML has problems escaping text (I have to use CDATA ugliness). Is there an easier way?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload