我有两个数组.我需要检查并查看其中一个元素是否出现在另一个元素中.
有没有比嵌套循环更有效的方法呢?我每个都有几千个元素,需要经常运行程序.
我正在尝试从文本文件中读取数据到我的java程序.但是,无论我把文件放在哪里,eclipse都会连续给我一个Source not found错误.
我在项目目录中创建了一个额外的sources文件夹,有问题的文件在它和项目的bin文件中,它仍然无法找到它.
我甚至把它的副本放在我的桌面上,并在它要求我浏览源查找路径时尝试指向eclipse.
无论我做什么都找不到文件.
这是我的代码,如果它是相关的:
System.out.println(System.getProperty("user.dir"));
File file = new File("file.txt");
Scanner scanner = new Scanner(file);
Run Code Online (Sandbox Code Playgroud)
另外,它说用户目录是项目目录,也有副本.
我不知道该怎么做.
谢谢,亚历克斯
在尝试下面的建议并再次刷新之后,我受到了许多错误的欢迎.
FileNotFoundException(Throwable).<init>(String) line: 195
FileNotFoundException(Exception).<init>(String) line: not available
FileNotFoundException(IOException).<init>(String) line: not available
FileNotFoundException.<init>(String) line: not available
URLClassPath$JarLoader.getJarFile(URL) line: not available
URLClassPath$JarLoader.access$600(URLClassPath$JarLoader, URL) line: not available
URLClassPath$JarLoader$1.run() line: not available
AccessController.doPrivileged(PrivilegedExceptionAction<T>) line: not available [native method]
URLClassPath$JarLoader.ensureOpen() line: not available
URLClassPath$JarLoader.<init>(URL, URLStreamHandler, HashMap) line: not available
URLClassPath$3.run() line: not available
AccessController.doPrivileged(PrivilegedExceptionAction<T>) line: not available [native method]
URLClassPath.getLoader(URL) line: not available …Run Code Online (Sandbox Code Playgroud) 我正在创建一个脚本供用户运行.我需要将输出重定向到我在脚本内创建的文件(hostname-date).
除了如何从同一个脚本中复制脚本的输出之外,我有所有的部分.我可以找到的所有示例都将脚本调用,然后将其调用到日志中,但这不是一个选项.
-Alex
我正在尝试重定向脚本的输出,并且需要在脚本内部调用它。
filename=uname -a
filename="$filename" date
2>&1 | tee $filename".txt"
Run Code Online (Sandbox Code Playgroud)
这就是我到目前为止所得到的,但这显然是错误的。我不太了解 SH 脚本,所以感谢帮助
-亚历克斯