关闭

java.lang.ArrayIndexOutOfBoundsException异常问题

标签: java异常excelpoi数组越界
534人阅读 评论(0) 收藏 举报

在开发一个JAVA GUI 程序的时候遇到的问题。在建立一个AbstractTableModle时,使用的是POI导入的Excel表格数据,然后先为模型定义了属性组,六个,但在利用Vector<String>导入数据的时候,每一行只给了五个数据。这个问题我理解为在前面定义的属性组里的属性个数已与模型绑定,而实际给的数据少于这预先绑定的数量时,则线程在利用表格模型建表时会尝试访问空的元组单元,因此发生数组下标越界问题。

报错信息如下:

Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 5
at java.util.Vector.get(Unknown Source)
at kernel.TableModel.getValueAt(TableModel.java:75)
at javax.swing.JTable.getValueAt(Unknown Source)
at javax.swing.JTable.prepareRenderer(Unknown Source)
at javax.swing.plaf.basic.BasicTableUI.paintCell(Unknown Source)
at javax.swing.plaf.basic.BasicTableUI.paintCells(Unknown Source)
at javax.swing.plaf.basic.BasicTableUI.paint(Unknown Source)
at javax.swing.plaf.ComponentUI.update(Unknown Source)
at javax.swing.JComponent.paintComponent(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JViewport.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JLayeredPane.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paintToOffscreen(Unknown Source)
at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source)
at javax.swing.RepaintManager$PaintManager.paint(Unknown Source)
at javax.swing.RepaintManager.paint(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at java.awt.GraphicsCallback$PaintCallback.run(Unknown Source)
at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source)
at sun.awt.SunGraphicsCallback.runComponents(Unknown Source)
at java.awt.Container.paint(Unknown Source)
at java.awt.Window.paint(Unknown Source)
at javax.swing.RepaintManager$4.run(Unknown Source)
at javax.swing.RepaintManager$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.prePaintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.access$1200(Unknown Source)
at javax.swing.RepaintManager$ProcessingRunnable.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)



0
0
查看评论

java.lang.ArrayIndexOutOfBoundsException(数组越界)处理方法

当你使用不合法的索引访问数组时会报数组越界这种错误,数组arr的合法错误范围是[0, arr.length-1];当你访问这之外的索引时会报这个错。例如:public class Test { public static void main(String[] args) { ...
  • qq_34646449
  • qq_34646449
  • 2017-07-26 14:36
  • 6208

Linux环境下 使用JXL生成Excel时发生java.lang.ArrayIndexOutOfBoundsException

java.lang.ArrayIndexOutOfBoundsException         at java.lang.System.arraycopy(Native Method)    &...
  • zljjava
  • zljjava
  • 2015-11-16 14:33
  • 838

问题一20150509——mybatis的配置文件useGeneratedKeys属性(报java.lang.ArrayIndexOutOfBoundsException)

在mybatis配置文件中的insert语句如下时 <insert id="insert" parameterType="TBookmark" > insert into t_bookmark (BOOKMARK_ID, BOOKM...
  • zhuhao717
  • zhuhao717
  • 2015-05-09 16:19
  • 1911

解决java.lang.ArrayIndexOutOfBoundsException问题(android:singleLine="true")

最近发现一个java.lang.ArrayIndexOutOfBoundsException崩溃问题。 布局代码如下:         android:layout_width="wrap_content"  ...
  • u011871239
  • u011871239
  • 2015-07-13 12:42
  • 462

java.lang.ArrayIndexOutOfBoundsException的问题

为求方便,用了ArrayList的indexOf方法,旨在解决遍历List的问题。结果反而导致出现了更大的问题。出现了ArrayIndexOutOfBoundsException异常,并且返回-1。 由于List中对象不存在,用list.get(-1)取值出错。这里比较特殊,获取List的时间在...
  • iadink
  • iadink
  • 2017-03-30 18:12
  • 1258

ibatis执行存储过程,java.lang.ArrayIndexOutOfBoundsException: 0

在项目开发中遇到一个问题,ibatis执行存储过程时报错          {call proc_stats_$statisticsType$()}   ]]>   错误日志如下:   ---...
  • lp19861126
  • lp19861126
  • 2017-04-17 15:00
  • 906

Jetty报ArrayIndexOutBoundsException:30305的解决方案

部分报错信息如下: java.lang.ArrayIndexOutOfBoundsException: 30305 at org.objectweb.asm.ClassReader.readUnsignedShort(Unknown Source) at org....
  • iamlihongwei
  • iamlihongwei
  • 2017-05-27 17:21
  • 1054

开发中常遇到到的问题二:java.lang.ArrayIndexOutOfBoundsException

开发常见错误ArrayIndexOutOfBoundsException(越界) 但你在取某个集合或数组的长度大的下标数据时就会报错,但保存没有定义数组长度的时候也会报错,这是我的一个理解。
  • u010217289
  • u010217289
  • 2017-12-14 15:01
  • 71

java.lang.ArrayIndexOutOfBoundsException: 2

1、错误描述java.lang.ArrayIndexOutOfBoundsException: 2 at report.service.impl.ExportServiceImpl$7.setSheetValue(ExportServiceImpl.java:2649) at utils.Exc...
  • you23hai45
  • you23hai45
  • 2015-11-14 00:05
  • 7409

ArrayList在多线程调用Add()添加元素时的下标越界问题(java.lang.ArrayIndexOutOfBoundsException)

最近在看《实战Java虚拟机》一书,看到有关锁与并发章节时,看到如下一个多线程使用ArrayList的例子:        两个线程t1和t2同时向numberList中添加数据,由于ArrayList是线程不安全的,因此会导致添加的数据有错误,这个我...
  • u010010428
  • u010010428
  • 2016-04-27 10:24
  • 5415
    个人资料
    • 访问:579次
    • 积分:25
    • 等级:
    • 排名:千里之外
    • 原创:2篇
    • 转载:0篇
    • 译文:0篇
    • 评论:0条
    文章存档