Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #29562
| From | Mike Amling <mamling@chaff.us> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: dealing with ClassLoaders... |
| Date | 2014-08-04 19:53 -0500 |
| Message-ID | <c4ao7sF1mehU1@mid.individual.net> (permalink) |
| References | <slrnltl6t2.fp3.avl@login.logic.tuwien.ac.at> <lrg69c$6r3$1@gregory.bnet.hr> <slrnltv8mj.fp3.avl@login.logic.tuwien.ac.at> |
On 8/4/14 10:12 AM, Andreas Leitgeb wrote:
> URL url=getSystemResource(name.replace('.', '/') + ".class");
> byte[] classData = new byte[1024*1024*10]; int len = 0;
> try {
> len = url.openConnection().getInputStream().read(classData);
> } catch (IOException e) {
> e.printStackTrace();
> }
You could buffer to a ByteArrayOutputStream.
InputStream source=getSystemResource(name.replace('.', '/') +
".class").openConnection().getInputStream();
ByteArrayOutputStream buffer=new ByteArrayOutputStream();
try {
for (int input; (input=source.read())>=0; ) {
buffer.write(input);
}
} catch (IOException i) {
Whatever
}
byte[] classData=buffer.toByteArray();
> This appears to work (from watching the debugger pass through it),
> although it is obviously quick'n'dirty. Most obviously, I'd like
> to get rid of the 10M-sized array, but I don't think I can ask the
> URL or the Stream about the exact size beforehand.
--Mike Amling
T25lIHJlYWQgZnJvbSBVUkwub3BlbkNvbm5lY3
Rpb24uZ2V0SW5wdXRTdHJlYW0gaXMgbm90IG5l
Y2Vzc2FyaWx5IHN1ZmZpY2llbnQu
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
dealing with ClassLoaders... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-07-31 19:40 +0000
Re: dealing with ClassLoaders... Martin Gregorie <martin@address-in-sig.invalid> - 2014-07-31 20:44 +0000
Re: dealing with ClassLoaders... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-01 14:22 +0000
Re: dealing with ClassLoaders... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-01 21:10 +0000
Re: dealing with ClassLoaders... Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-08-01 17:32 -0400
Re: dealing with ClassLoaders... Joerg Meier <joergmmeier@arcor.de> - 2014-08-02 01:21 +0200
Re: dealing with ClassLoaders... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-02 00:00 +0000
Re: dealing with ClassLoaders... Martin Gregorie <martin@address-in-sig.invalid> - 2014-08-01 21:45 +0000
Re: dealing with ClassLoaders... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-01 23:14 +0000
Re: dealing with ClassLoaders... Martin Gregorie <martin@address-in-sig.invalid> - 2014-08-02 00:35 +0000
Re: dealing with ClassLoaders... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-05 15:38 +0000
Re: dealing with ClassLoaders... Silvio <silvio@internet.com> - 2014-08-01 13:31 +0200
Re: dealing with ClassLoaders... Silvio <silvio@internet.com> - 2014-08-01 13:37 +0200
Re: dealing with ClassLoaders... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-01 16:06 +0000
Re: dealing with ClassLoaders... "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2014-08-01 13:19 +0100
Re: dealing with ClassLoaders... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-01 15:51 +0000
Re: dealing with ClassLoaders... Josip Almasi <joe@vrspace.org> - 2014-08-01 15:55 +0200
Re: dealing with ClassLoaders... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-04 15:12 +0000
Re: dealing with ClassLoaders... Mike Amling <mamling@chaff.us> - 2014-08-04 19:53 -0500
Re: dealing with ClassLoaders... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-05 15:16 +0000
Re: dealing with ClassLoaders... Josip Almasi <joe@vrspace.org> - 2014-08-08 11:53 +0200
Re: dealing with ClassLoaders... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-08 18:46 +0000
Re: dealing with ClassLoaders... Josip Almasi <joe@vrspace.org> - 2014-08-10 13:22 +0200
Re: dealing with ClassLoaders... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-12 17:16 +0000
csiph-web