如何使用camel-exec在Linux中移动文件?(How do you move a file in Linux using camel-exec?)
我是骆驼的新手。 我试图用它在Linux中将文件从一个位置移动到另一个位置。 为了实现这一点,我试图使用camel-exec :
这是我尝试过的:
from("direct:exec") .to("exec:mv test/directorySource test/directoryDestination")
当我运行我的代码时,我收到以下错误:
Unable to execute command [args=[], executable = mv null null timeout=..., outFile=null. workingDir=null, useStdeirOnEmptyStdout=false]
注意:我使用的是Java DSL,而不是骆驼的XML版本。
我有一种感觉,我从命令中遗漏了一些东西,告诉它输入应该是什么,但我不确定。 我试图按照上面链接中的“执行Java”中的示例,但我无法让它工作。
有谁知道如何完成这个或我可能做错了什么?
I am new to camel. I am trying to use it to move a file from one location to another in Linux. To accomplish this, I am trying to use camel-exec:
Here is what I tried:
from("direct:exec") .to("exec:mv test/directorySource test/directoryDestination")
When I run my code, I get the following error:
Unable to execute command [args=[], executable = mv null null timeout=..., outFile=null. workingDir=null, useStdeirOnEmptyStdout=false]
Note: I am using the Java DSL, not the XML version of camel.
I have a feeling I am missing something from the command that tells it what the input should be, but I'm not sure. I tried to follow the examples in the link above for "Executing Java," but I haven't been able to get it to work.
Does anyone know how to accomplish this or what I might be doing wrong?
原文:https://stackoverflow.com/questions/36332413
最满意答案
你的对角线检查都是相同的方向。
grid[x+1, y+1]
和grid[x-1,y-1]
都是从左上到右下的相同对角线。 对于另一个对角线,您需要添加到一个索引并从另一个索引中减去。如果
i
是偏移量,0-3,那么一个对角线是:grid[x+i, y+i]
另一个对角线是:
grid[x+i, y-i]
您必须将最终的
for
循环调整for
正确的索引。Your diagonal checks both are the same direction.
grid[x+1, y+1]
andgrid[x-1,y-1]
are both in the same diagonal, from top left to bottom right. For the other diagonal you need to add to one index and subtract from the other.if
i
is the offset, 0-3, then one diagonal is:grid[x+i, y+i]
and the other diagonal is:
grid[x+i, y-i]
You'll have to adjust your final
for
loops to the correct indices.
相关问答
更多-
我会创建一个获取元素的方法,如果坐标无效,则返回一个默认值。 只需使用默认值即可查找所需内容。 public char getWithDefault(int row, int col, char default ) { if ((0 <= row) && ( row < board.length) && (0<=col) && (col < board[row].length)) { return board[row][col]; } return default; } p ...
-
最简单的算法可能是: for every direction for every coordinate check whether the next 3 elements in this direction exist and are the same 在代码中: final int maxx = 7; final int maxy = 6; char winner(char[][] board) { int[][] directions = {{1,0}, {1,-1} ...
-
你的对角线检查都是相同的方向。 grid[x+1, y+1]和grid[x-1,y-1]都是从左上到右下的相同对角线。 对于另一个对角线,您需要添加到一个索引并从另一个索引中减去。 如果i是偏移量,0-3,那么一个对角线是: grid[x+i, y+i] 另一个对角线是: grid[x+i, y-i] 您必须将最终的for循环调整for正确的索引。 Your diagonal checks both are the same direction. grid[x+1, y+1] and grid[x-1, ...
-
检查2D阵列中的对角线(Checking diagonals in a 2D array)[2023-12-13]
有两点需要指出。 首先,在您的情况下,您正在检查gameBoard[x-2][y-2] ,这应该是gameBoard[x-2][y+2] 其次,您应该在函数末尾添加一个return false ,以便在检查失败时返回false。 如果不添加return语句,它将不返回任何内容,因此undefined 。 There are two things to be pointed out. Firstly, in your condition you're checking for gameBoard[x-2][y ... -
Java二维数组对角线(Java 2D array diagonals)[2022-08-17]
解决这个问题的小窍门。 很明显,您在矩阵row和column索引计算中遇到了错误,并且您的循环不覆盖其中的所有单元格。 最简单的方法来检查它,只是打印出来控制台。 我可以看到,你有问题for (int row = 0; row < numSpots - 1; row++) 。 第一次迭代,当numSpots=1它跳过这个循环。 正确的是for (int row = 0; row <= numSpots - 1; row++) 。 让我给你一些关于你的例子的笔记。 我可以看到矩阵的上下两部分用相反的方向检查, ... -
二维阵列对角线检查“X”(2D array diagonal checking for “X”)[2023-10-12]
我假设问题是如何让代码只显示警报一次 - 你应该设置一个标志,用户有一个标志,当游戏结束时,最后使用警报。 现在警报在循环中,因此每次循环都会触发警报。 I assume the question is how to make the code to show the alert only once - you should set a flag for which user has one and when the game has ended, then use the alert in the end ... -
欧拉项目问题#11(Project Euler Problem #11)[2023-07-31]
你知道网格是20x20,所以只需将它粘贴到一个文本文件中并像阅读矩阵一样阅读它: for (int i = 0; i < 20; ++i) for (int j = 0; j < 20; ++j) inFile >> mat[i][j]; 然后做明显的事情:对于每个元素[i][j] ,向下4个元素,向右4个,向右4个,向左4个,找到产品。 如果因为边界而无法获得4个元素,请忽略可以获得的元素。 没有必要像你似乎在做的那样使这个复杂化。 保持简单,因为这是一个简单的问题,如果你过时了 ... -
尝试这个, /* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ class Ideone { public static void main (String[] args){ ...
-
这是正确的代码。 我建议任何尝试这个问题的人都会花一些时间用铅笔和纸来实际看到这个模式。 这个问题本身很容易。 #include
using namespace std; int input [20][20] ={{8,2,22,97,38,15,0,40,0,75,4,5,7,78,52,12,50,77,91,8}, {49,49,99,40,17,81,18,57,60,87,17,40,98,43,69,48,4,56,62,0}, {81,49,31,73,55,79, ... -
欧拉项目#11(Project Euler #11)[2024-02-19]
您正在检查相同的对角线。 在网格中绘制您正在检查的线条(在纸上),以便轻松查看。 改变其中一个从X中加入并从Y中减去(或者反过来)。 You are checking the same diagonal lines both times. Draw the lines you are checking in the grid (on paper), to see this easily. Change one of them to add from X and subtract from Y (or the ...