Tag: indexoutofboundsexception

java中的video隐写术

我正在为我的项目实施video隐写术。 我从这里看到了算法。 我已经尝试并测试了代码,嵌入部分工作正常。 但我遇到了readByte的问题,这是VideoSteganography类中的最后一个方法。 该方法给出了ArrayIndexOutOfBoundsException 。 以下是方法。 我将参数传递给 String fname = jTextField3.getText(); File fil = new File(fname); String password = “123456”; SteganoInformation cls = new SteganoInformation(fil); VideoSteganography.retrieveFile(cls, password, true); 而方法是 public static boolean retrieveFile(SteganoInformation info, String password, boolean overwrite) { File dataFile= null; features= info.getFeatures(); try { masterFile= info.getFile(); byteArrayIn= new byte[(int) masterFile.length()]; DataInputStream in= […]

如何在解析CSV行中的空位置时避免触发ArrayIndexOutOfBoundsException?

String[] values = line.split(“,”); Long locId = Long.parseLong(replaceQuotes(values[0])); String country = replaceQuotes(values[1]); String region = replaceQuotes(values[2]); String city = replaceQuotes(values[3]); String postalCode = replaceQuotes(values[4]); String latitude = replaceQuotes(values[5]); String longitude = replaceQuotes(values[6]); String metroCode = replaceQuotes(values[7]); String areaCode = replaceQuotes(values[8]); //… public String replaceQuotes(String txt){ txt = txt.replaceAll(“\””, “”); return txt; } 我正在使用上面的代码来解析具有以下格式的数据的CSV: 828,”US”,”IL”,”Melrose Park”,”60160″,41.9050,-87.8641,602,708 […]

限制JavaFX TextField的字符数会导致撤消时出现IndexOutOfBounds

我要求限制用户可以输入到TextField JavaFX控件中的字符数。 我像这样扩展了TextField public class LengthLimitedTextField extends TextField { /** * @param maxCharacters The max allowed characters that can be entered into this {@link TextField}. */ public LengthLimitedTextField(final int maxCharacters) { final TextField thisField = this; this.textProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observable, String oldValue, String newValue) { // Force correct length by deleting […]

java.lang.StringIndexOutOfBoundsException:在= sqlite数据库中索引= 0 length = 0

我试图用这段代码打开一个可写的SQLite数据库…… public DataAdapterForServieClass open() throws SQLException { db = DBHelper.getWritableDatabase(); return this; } 但是我在db = DBHelper.getWritableDatabase();上收到以下错误db = DBHelper.getWritableDatabase(); 线… 06-10 11:58:13.995: ERROR/AndroidRuntime(548): FATAL EXCEPTION: main 06-10 11:58:13.995: ERROR/AndroidRuntime(548): java.lang.StringIndexOutOfBoundsException: index=0 length=0 06-10 11:58:13.995: ERROR/AndroidRuntime(548): at android.app.ContextImpl.validateFilePath(ContextImpl.java:1518) 06-10 11:58:13.995: ERROR/AndroidRuntime(548): at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:725) 06-10 11:58:13.995: ERROR/AndroidRuntime(548): at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:221) 06-10 11:58:13.995: ERROR/AndroidRuntime(548): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:149) 这是我的DBHelper类的代码…… static class DatabaseHelper […]

未捕获并忽略ArrayIndexOutOfBoundsException

我想捕捉并忽略和ArrayIndexOutOfBoundsException错误(基本上它不是我可以控制的东西,所以我需要我的程序继续前进)。 但是我的try / catch对似乎没有捕获exception并忽略它。 希望你能挑出我做错了什么。 此行发生exception content = extractor.getTextFromPage(page); 这是我的代码: for(int page=1;page<=noPages;page++){ try{ System.out.println(page); content = extractor.getTextFromPage(page); } } catch (ArrayIndexOutOfBoundsException e){ System.out.println("This page can't be read"); } } 线程“main”中的exceptionjava.lang.ArrayIndexOutOfBoundsException:来自com的com.lowagie.text.pdf.CMapAwareDocumentFont.decode(未知来源)的com.lowagie.text.pdf.CMapAwareDocumentFont.decodeSingleCID(未知来源)中的索引:02无效.lowagie.text.pdf.parser.PdfContentStreamProcessor.decode(Unknown Source)at com.lowagie.text.pdf.parser.PdfContentStreamProcessor.displayPdfString(Unknown Source)at com.lowagie.text.pdf.parser.PdfContentStreamProcessor $ ShowText.invoke (未知来源)com.lowagie.text.pdf.parser.PdfContentStreamProcessor.invokeOperator(未知来源)com.lowagie.text.pdf.parser上的com.lowagie.text.pdf.parser.PdfContentStreamProcessor.processContent(未知来源) com.pdfextractor.main.Extractor.main上的.pdfTextExtractor.getTextFromPage(未知来源)(Extractor.java:64) 编辑:我已将try / catch放在for循环中 并添加了堆栈跟踪 并删除了index = 1

使用Java 8构造时Bean创建的ArrayOutOfBoundsException

当我使用Java 8function时,我在服务启动(Bean创建)上得到一个ArrayIndexOutOfBoundsException 。 Java 8已经建立并一直在运行。 代码编译正确。 在服务启动时,服务无法侦听端口,因为bean未创建。 当我更改代码(删除java 8构造)时,服务启动,一切正常。 这是我正在使用的代码(服务启动的工作代码): for (Item itemObject : response) { if (itemObject.hasId()) { idList.add(String.valueOf(itemObject.Id()); } } 使用Java 8构造的相同代码: response.parallelStream() .filter(itemObject -> itemObject.hasId()) .map(itemObject -> itemObject.getId()) .forEach(id -> idList.add(id)); 包含此代码的类的bean是使用组件扫描创建的。 当使用第二个代码块代替第一个代码块时,以下是exception消息: Exiting with throwable: java.lang.IllegalArgumentException: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: URL [jar:file:/workspace/…/GetContainerIdForFcSkuAdapter.class]; nested exception is java.lang.ArrayIndexOutOfBoundsException: 51880 java.lang.IllegalArgumentException: […]

ArrayList:IndexOutOfBoundsexception问题

我正在制作一个程序来查找素数。 我在两个ArrayList存储素数和所有正整数(现在直到100)。 这是代码: import java.util.ArrayList; public class PrimeNumbers { static ArrayList num = new ArrayList(); static ArrayList prime = new ArrayList(); public static void main(String[] args) { prime.add(2); prime.add(3); prime.add(5); for (int z = 1; z<=100; z++){ num.add(z); } outer: for (int a = 1; a <=num.size(); a++){ inner: for (int b = 1; b […]

为什么我得到索引越界exception?

我已经制作了这个代码,将整个基数为10的数字转换成二进制数。 我相信的代码是它需要的一切,但我不能让我使用ArrayLists。 我花了几个小时在这个网站和其他尝试无数的改变无济于事。 我已经得到了没有和错误编译的代码,但是一旦我输入一个int,程序崩溃了。 这是代码: import java.util.Scanner; import java.util.ArrayList; public class BinaryConverter { public static void main(String[] args) { Scanner in = new Scanner(System.in); ArrayList binary = new ArrayList(); int a = in.nextInt(); binary = binaryConverter(a); for (int i = binary.size(); i > -1; i = i – 1){ System.out.print(binary.get(i)); } } public static ArrayList […]

“索引:68,大小:10”是什么意思?

我收到了一个错误 java.lang.IndexOutOfBoundsException: Index: 68, Size: 10 我知道这个错误意味着什么..我试图读取一个不存在的数组的位置。 我不知道this Index: 68, Size: 10这是什么意思..我试图读取一个只有10个位置的数组的位置68?

避免索引超出范围的exception

我正在使用数组列表来存储有关在屏幕上移动对象的数据。 我怀疑这是因为我的渲染器和我的逻辑在不同的线程上运行,但有时当从列表中删除数据时,我得到一个indexOutOfBoundsException。 我已经采取了我能想到的所有步骤来避免这种情况,包括try / catch,但有时会发生exception。 这是我的渲染器线程的一部分,似乎导致exception。 public void drawMobs(GL10 gl) { boolean playing = MyLaunchActivity.getPlaying(); if(playing == true){ try{ ArrayList mobDat = Play.getMobDat(); while (currentLoadSpace < mobDat.size()){ if(!mobDat.isEmpty() || currentLoadSpace < mobDat.size()){ loadObject = mobDat.get(currentLoadSpace); float loadCoordX = Float.parseFloat(mobDat.get(currentLoadSpace + 2)); float loadCoordY = Float.parseFloat(mobDat.get(currentLoadSpace + 3)); /*some rendering*/ currentLoadSpace+=4; } } }catch( ArrayIndexOutOfBoundsException e){ […]