【java – 使用Stream读取文件并跟踪当前索引】教程文章相关的互联网学习教程文章

java – 将数组作为具有不同起始索引的参数传递【代码】

如何在Java中传递数组,我可以为数组参数指示不同的起始索引(第0个索引).在C中,您可以传递这样的数组myMethed(myArray + 3); // passing method where begin index is 4th element...void myMethod(int* arr) {int val = arr[0]; // refers to the 4th elementint val2 = arr[1]; // 5th element }我怎样才能在Java中做类似的事情.我尝试使用Arrays.copyOfRange复制数组的一个子集,但我不想要一个单独的副本,但是同一个数组具有不同...

使用java中的itext库为合并的pdf创建索引文件(TOC)【代码】

我使用iText通过使用PDFCopy合并大量PDF来创建单个PDF.我需要在本文档的开头创建一个TOC(而不是书签),其中包含指向每个源PDF的第一页的可点击链接. 合并pdf的代码Document PDFJoinInJava = new Document(); PdfCopy PDFCombiner = new PdfCopy(PDFJoinInJava, outputStream); PdfCopy.PageStamp stamp; PDFJoinInJava.open(); PdfReader ReadInputPDF;List<InputStream> pdfs = streamOfPDFFiles; List<PdfReader> readers = new A...

java – 为什么二维数组中的对象的索引返回-1?【代码】

所以我有这个方法:public static int[][] executeRules(int[][] array){int rowNumber = 0;for(int[] row : array){for (int cell:row){int index = Arrays.asList(array).indexOf(cell);System.out.println(index);int[] surroundingCells = getSurroundingCells(index);int liveCells = 0;for(int aSurroundingCell: surroundingCells){if(aSurroundingCell == 1){liveCells++;}}//If cell is deadif (cell == 0){//Bring cell ...

java – Spinner中的索引超出界限【代码】

有4个Spinnners:resiko,untung1,untung2,untung3 用户首先选择resiko继续,应用程序将显示哪个Spinner可见(untung1 / untung2 / untung3) 试图制作动态数据Spinner,当你点击第一个Spinner内的一个项目时,其他的将会消失,并且到目前为止所需的一个将是可见的.问题是当我从Spinner resiko中选择“tinggi”时,它会出错:java.lang.IndexOutOfBoundsException 我也试过阅读其他帖子,但仍不确定我该怎么做.我之前尝试使用getSelectedIte...

java – Weblogic 12c(12.1.3) – 字符串索引超出范围:51968【代码】

我正在尝试在Weblogic 12.1.3上部署Spring Boot Web应用程序. 当我从控制台部署时,我得到以下错误(在应用程序上)Message icon - Error Unable to access the selected application. Message icon - Error String index out of range: 51968 Message icon - Error String index out of range: 51968 Message icon - Error String index out of range: 51968另一方面,它从Intellij IDEA和autodeploy文件夹成功部署.此外,在其他开发机...

java – 重新介绍“未知的初始字符集索引”错误?【代码】

我有一个连接到mysql服务器的Java客户端应用程序.客户端和服务器都在docker容器中运行. 我注意到官方的mysql Docker镜像最近更新了mysql服务以运行版本:’8.0.1-dmr’ 由于此更改,我的Java客户端应用程序无法连接到mysql实例;它失败并出现以下错误:Caused by: java.sql.SQLException: Unknown initial character set index '255' received from server. Initial client character set can be forced via the 'characterEncoding'...

java – 如何添加com.google.gson.JsonArray的特定索引?【代码】

com.google.gson.JsonArray具有将附加元素的add方法.如果我想在特定索引处添加,该怎么做? 我尝试使用这种代码在第0个索引处添加元素.我正在寻找更好的东西,而无需实例化新的JsonArray.JsonArray newArray = new JsonArray(); newArray.add(new JsonPrimitive(3)); for (int i = 0; i < myArray.size(); i++) {newArray.add(myArray.get(i)); }解决方法:由于JsonArray没有插入方法,这意味着你必须自己创建.它会在您选择的位置插入数...

java – 使用带有流的hashmap时的索引【代码】

我有一个团队的HashMap,我需要打印出来.它们需要被索引并按一些参数排序(不相关).一切正常,除了索引部分,我在某种程度上工作,但感觉不对.int i=0;public void printTable() {StringBuilder sb = new StringBuilder();i = 0;table.keySet().stream().map(key -> table.get(key)).sorted(Comparator.comparing(Team::getPoints).thenComparing(Team::goalDifference).reversed().thenComparing(Team::getName)).forEach(team -> sb.a...

java – 按值和索引搜索数组【代码】

我有一个排序的整数数组,我想在其上执行搜索.该数组可以具有重复值.如果我搜索重复的元素,那么它应该返回元素的第一个实例的索引. 如果我使用Arrays.binarySearch(),那么它不一定会给出搜索到的元素的第一个实例的索引.例子可见here:int[] A = {10,20,21,24,24,24,24,24,30,40,45} ; int idx = Arrays.binarySearch(A,24) ;哪里,idx将是5.我希望它是3.我之前通过创建一个类对来解决了这个问题:class Pair implements Comparable<...

java – 禁用获取p2存储库索引【代码】

我们目前正在设置maven和tycho来构建eclipse插件.按照示例和文档,我们添加了一些布局为p2的存储库,如下所示:<repository><id>eclipse-indigo</id><layout>p2</layout><url>http://download.eclipse.org/releases/indigo</url> </repository>现在,每次我们执行pom时,maven都会“获取”p2索引,这需要相当长的时间.我们看到很多线条[INFO] Fetching p2.index (0B of 96B at 0B/s) from http://download.eclipse.org/releases/indigo/...

java – 在Neo4j中编制索引【代码】

我想知道当需要基于某个节点类型或字段的多个indecies时,什么是更好的方法.例如,假设我想要一个学生图表,并希望按照他们的学校和身份对其进行索引. 据我所知,每个学校都可以有这样的索引:// add student Index<Node> index = this.graphDb.index().forNodes(schoolName); Node node = this.graphDb.createNode(); node.setProperty("id", studentId); index.add(node, "id", studentId);// get student Index<Node> index = this....

Java ArrayList IndexOutOfBoundsException索引:1,大小:1【代码】

我正在尝试用Java读取某个文件并将其转换为多维数组.每当我从脚本中读取一行代码时,控制台会说:Caused by: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1我知道这个错误是在编码无法达到特定索引时引起的,但我现在还不知道如何修复它. 这是我编码的一个例子.int x = 1; while (scanner.hasNextLine()) {String line = scanner.nextLine();//Explode string lineString[] Guild = line.split("\\|");//Add that value t...

java – 将文档id写入索引的异常;可能的分析错误【代码】

我在索引文档时遇到上述错误.<field name="a_suggest" type="my_suggest_field" indexed="true" stored="false"/> <field name="b_suggest" type="my_suggest_field" indexed="true" stored="false" /> <field name="c_suggest" type="my_suggest_field" indexed="true" stored="false"/><fieldType name="my_suggest_field" class="solr.TextField" positionIncrementGap="100"><analyzer type="index"><tokenizer class="solr.Wh...

java – 按比例索引转换音符【代码】

我正在尝试创建一种算法,根据给定的比例和转置因子向上或向下转换音符. 当前算法:public Note getNoteByScale(Scale scale, int transposeFactor) {int newPitch = scale.getScaleIndex(this.pitch) + transposeFactor;int newOctave = this.octave;if (newPitch > 6) {newPitch -= 7;newOctave++;}if (newPitch < 0) {newPitch += 7;}return Note.createNote(scale.getNotesInScale().get(newPitch),newOctave, this.duration); ...

java – 重建Maven索引坚持0%

我正在尝试rebuild the Maven index in Eclipse,但它已经停留在0%几个小时. 尝试添加依赖项时,我找不到任何结果.我已经尝试以管理员身份运行Eclipse并在启动时勾选“更新存储库”,但这两个选项都没有用. 我使用的是Windows 8.1企业版 解决方法:>离开Eclipse>转到[your-workspace-folder]>删除.metadata / .plugins / org.eclipse.m2e.core / nexus>删除.metadata / .plugins / org.maven.ide.eclipse / nexus>重启Eclipse 如果它没...