我一直在寻找各地,我开始相信除了拥有全局变量之外别无他法,但我相信stackoverflow.com中的大师可能能够帮助我:
在bash中有没有办法通过向它传递参数来捕获函数?
例如,trap <function_name> <arg_1> <arg_2> SIGINT?
这是一个代码片段,但基本上我想要做的是从名为'listings.txt'的文件中读取并写入名为'overview.txt'的文件.我想从'listings.txt'中取出信息并将它们按原样放入'overview.txt'中(稍后我将弄清楚其余部分).
创建文件'overview.txt'并显示循环遍历文件'listings.txt'并写入'overview.txt'.但是,一旦我打开文件'overview.txt',它就是空的.
有人可以通过快速浏览我的代码并发现错误的东西吗?
package yesOverview;
import java.io.BufferedReader;
import java.io.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
public class yesOverview {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String strInput = "foo.bar";
System.out.print("Please enter the listings file (the full path to the file): ");
strInput = input.next();
//This makes sure that the inputed file is listings.txt as required for KET1 task 2
while (strInput.contains("listings.txt") == false) {
System.out.print("Incorrect file. Please enter listings …Run Code Online (Sandbox Code Playgroud) 正如标题所暗示的那样,我在一个帖子中遇到了这个错误.
令人讨厌的LOC看起来像这样:
for (int i = 0; i < objectListSize; i++) {
logger.INFO("Loop repeat: "+i+" ...", true);
final Double discreteScore = sp.getDouble(superPeerSocket);
final int expectedObjectIDs = sp.getInteger(superPeerSocket);
final String discreteObjects[] = new String[expectedObjectIDs];
for ( int j = 0; j < expectedObjectIDs; j++)
discreteObjects[j] = sp.getString(superPeerSocket);
htPlus.attachInitialDiscreteList2L1(discreteScore, discreteObjects);
}
Run Code Online (Sandbox Code Playgroud)
最后的String discreteObjects []声明是我得到错误的地方.我在一个线程中运行此代码.当我得到这个时,我有两个当前活动的线程.我也尝试过使用eclipse中的MAT工具.这里是一些内部图表文件的链接:
PLC图表文件(dropbox URL)
如果有人对这个问题有任何想法,我将不胜感激.PS:我想删除循环虽然它在第一次循环传递中失败了.
(当程序失败时,我在输出中得到这个)
Expected data size: 10
Repeat: 0 ...
java.lang.OutOfMemoryError: Java heap space
Dumping heap to java_pid3793.hprof ...
Heap dump file created [1404020 bytes in 0.015 …
Run Code Online (Sandbox Code Playgroud)
Run Code Online (Sandbox Code Playgroud)Run Code Online (Sandbox Code Playgroud)