This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WatchKey key = watcher.take(); | |
for (WatchEvent<?> event: key.pollEvents()) { | |
WatchEvent.Kind<?> kind = event.kind(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean isMatchPattern(GRPattern GRPattern, Path file) { | |
PathMatcher matcher = FileSystems.getDefault().getPathMatcher(GRPattern.getPatternSyntax() + | |
Paths.get(GRPattern.getPathPattern()).toString()); | |
Path name = file.getFileName(); | |
return name != null && matcher.matches(file); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void copyRemoteToLocal(Session session, String from, String to, String fileName) throws JSchException, IOException { | |
from = from + File.separator + fileName; | |
String prefix = null; | |
if (new File(to).isDirectory()) { | |
prefix = to + File.separator; | |
} | |
// exec 'scp -f rfile' remotely | |
String command = "scp -f " + from; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void copyLocalToRemote(Session session, String from, String to, String fileName) throws JSchException, IOException { | |
boolean ptimestamp = true; | |
from = from + File.separator + fileName; | |
// exec 'scp -t rfile' remotely | |
String command = "scp " + (ptimestamp ? "-p" : "") + " -t " + to; | |
Channel channel = session.openChannel("exec"); | |
((ChannelExec) channel).setCommand(command); | |
// get I/O streams for remote scp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] arg) throws IOException, JSchException { | |
String remoteA = "/tmp/scp/remote-a/"; | |
String remoteB = "/tmp/scp/remote-b/"; | |
String local = "/tmp/scp/local/"; | |
String fileName = "abc.txt"; | |
String user = "chanaka"; | |
String host = "localhost"; | |
int port = 22; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Copy the file "foobar.txt" from a remote host to the local host | |
$ scp username@remotehost:foobar.txt /some/local/directory | |
Copy the file "foobar.txt" from the local host to a remote host | |
$ scp foobar.txt username@remotehost:/some/remote/directory | |
Copy the directory "foo" from the local host to a remote host's directory "bar" | |
$ scp -r foo username@remotehost:/some/remote/directory/bar | |
Copy the file "foobar.txt" from the local host to a remote host using port 2264 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set http_proxy=http://cache.mrt.ac.lk:3128 | |
set https_proxy=https://cache.mrt.ac.lk:3128 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void getVariableNames() { | |
Field[] fields = MyClass.class.getDeclaredFields(); | |
for (Field f : fields) { | |
if (Modifier.isStatic(f.getModifiers())) { | |
System.out.println(f.getName()); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Git releases -- | |
Ex: tag = v1.0-alpha1 | |
Add tag | |
---------------------------------------------- | |
git tag -a [tag] -m "Released [tag]" | |
git push origin [tag] | |
Delete tag | |
---------------------------------------------- |