15
15
import org .xml .sax .SAXException ;
16
16
17
17
import java .io .ByteArrayInputStream ;
18
- import java .io .ByteArrayOutputStream ;
19
18
import java .io .IOException ;
20
19
import java .io .InputStream ;
21
20
import java .io .InputStreamReader ;
@@ -176,10 +175,10 @@ public void process(final String baseUrl) {
176
175
177
176
private InputStream getXmlDocsViaSru (final StringBuilder srUrl ) {
178
177
try {
179
- ByteArrayInputStream byteArrayInputStream = retrieve (srUrl , startRecord , maximumRecords );
178
+ InputStream inputStreamOfURl = retrieveUrl (srUrl , startRecord , maximumRecords );
180
179
DocumentBuilderFactory factory = DocumentBuilderFactory .newInstance ();
181
180
DocumentBuilder docBuilder = factory .newDocumentBuilder ();
182
- Document xmldoc = docBuilder .parse (byteArrayInputStream );
181
+ Document xmldoc = docBuilder .parse (inputStreamOfURl );
183
182
184
183
Transformer t = TransformerFactory .newInstance ().newTransformer ();
185
184
StringWriter stringWriter = new StringWriter ();
@@ -193,6 +192,7 @@ private InputStream getXmlDocsViaSru(final StringBuilder srUrl) {
193
192
startRecord = nextRecordPosition ; // grenzwert : wenn maximumRcords > als in echt
194
193
195
194
return new ByteArrayInputStream (stringWriter .toString ().getBytes ());
195
+
196
196
}
197
197
catch (final IOException | TransformerException | SAXException | ParserConfigurationException e ) {
198
198
throw new MetafactureException (e );
@@ -207,7 +207,7 @@ private int getIntegerValueFromElement(final Document xmlDoc, final String tagNa
207
207
return 0 ;
208
208
}
209
209
210
- private ByteArrayInputStream retrieve (StringBuilder srUrl , int startRecord , int maximumRecords ) throws IOException {
210
+ private InputStream retrieveUrl (StringBuilder srUrl , int startRecord , int maximumRecords ) throws IOException {
211
211
final URL urlToOpen =
212
212
new URL (srUrl .toString () + "&maximumRecords=" + maximumRecords + "&startRecord=" + startRecord );
213
213
final HttpURLConnection connection = (HttpURLConnection ) urlToOpen .openConnection ();
@@ -218,10 +218,7 @@ private ByteArrayInputStream retrieve(StringBuilder srUrl, int startRecord, int
218
218
}
219
219
InputStream inputStream = getInputStream (connection );
220
220
221
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream ();
222
-
223
- inputStream .transferTo (outputStream );
224
- return new ByteArrayInputStream (outputStream .toByteArray ());
221
+ return inputStream ;
225
222
}
226
223
227
224
private InputStream getInputStream (final HttpURLConnection connection ) {
0 commit comments