简体   繁体   English

Java:从InputStreamReader中获取InputStream

[英]Java: get InputStream out of an InputStreamReader

Is it possible to get an InputStream out of an InputStreamReader instance? 是否可以从InputStreamReader实例中获取InputStream? If yes, how? 如果是,怎么办?

EDIT: i'm reading a binary file over network, so i need to read bytes, not chars. 编辑:我正在通过网络读取二进制文件,所以我需要读取字节,而不是字符。 I haven't found a way to do this with an InputStreamReader.... 我还没有找到使用InputStreamReader做到这一点的方法。

Not without reflection, no... and I really wouldn't recommend using reflection here. 不是没有反射,没有...我真的不建议在这里使用反射。 (You would be very implementation-specific.) (您将非常依赖于实现。)

Usually you shouldn't care about which implementation of Reader is being used at all, so you wouldn't even know it was an InputStreamReader ... let alone try to get access to the underlying InputStream . 通常,您根本不需要关心使用哪种Reader实现,因此您甚至都不知道它是InputStreamReader ……更不用说尝试访问基础InputStream

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM