java.lang.NullPointerException: Attempt to invoke virtual method 'int java.io.InputStream.read(byte[
来源:互联网 发布:java中map的用法详解 编辑:程序博客网 时间:2024/05/23 11:13
<span style="font-family: Arial, Helvetica, sans-serif;"></span>
InputStream inStream =getClass().getResourceAsStream(Path);FileOutputStream fs = new FileOutputStream(newPath);byte[] buffer = new byte[1024*5];while ((byteread = inStream.read(buffer )) != -1) {bytesum += byteread; System.out.println(bytesum);fs.write(buffer, 0, byteread);}inStream.close();
</pre><pre name="code" class="java"><pre name="code" class="java"><pre name="code" class="java">在做文件操作的时候 <pre name="code" class="java">inStream.read(buffer ) 报的<span style="font-family: Arial, Helvetica, sans-serif;">这个</span><span style="font-family: Arial, Helvetica, sans-serif;">异常 原因是因为 </span><span style="font-family: Arial, Helvetica, sans-serif;">InputStream 不能被实例化</span>
解决方法
</pre><pre name="code" class="java">InputStream inStream =getClass().getResourceAsStream(Path); 改成 FileInputStream inStream = new FileInputStream(<span style="font-family: Arial, Helvetica, sans-serif;">Path</span><span style="font-family: Arial, Helvetica, sans-serif;">);</span>
0 0
- java.lang.NullPointerException: Attempt to invoke virtual method 'int java.io.InputStream.read(byte[
- java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()'
- java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()'
- java.lang.NullPointerException: Attempt to invoke virtual method
- java.lang.NullPointerException: Attempt to invoke virtual method 'void java.io.BufferedOutputStream.
- Android程序报错:java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.
- Android程序报错:java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View
- java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getImporta..
- error: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getIm
- Android异常 NullPointerException: Attempt to invoke virtual method int java.lang.Integer.intValue()
- java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getImportant
- java.lang.NullPointerException Attempt to invoke virtual method 'int android.widget.Editor
- java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getImportant
- Attempt to invoke virtual method 'int java.lang.Integer.intValue()
- Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Str
- java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(ja
- java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.content.
- java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.widget.CheckBox.is
- 被苹果驳回,We discovered one or more bugs in your app when reviewed on iPhone......
- 1104
- spring + Quartz 入门demo
- 冒烟自动化测试介绍(1)
- 游戏服务器关于玩家数据的解决方案
- java.lang.NullPointerException: Attempt to invoke virtual method 'int java.io.InputStream.read(byte[
- 【UML】时序图和协作图
- STM32和大小端模式
- Linux Top 命令解析 比较详细
- 练习
- mysql 中 character set 与 collation 的点滴理解
- 关于实现ID池的小讨论
- Vmstat命令详解
- Java DaemonThread(守护线程)