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
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
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
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
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
Path dir = Paths.get("/tmp"); | |
WatchService watcher = FileSystems.getDefault().newWatchService(); | |
WatchKey key = dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY); |
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
// BinarySearchTree.cpp : Defines the entry point for the console application. | |
// L.D.C.Lakmal | |
#include "stdafx.h" | |
#include <iostream> | |
using namespace std; | |
typedef int element; |
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
// BinaryTree.cpp : Defines the entry point for the console application. | |
// L.D.C.Lakmal | |
#include "stdafx.h" | |
#include <iostream> | |
using namespace std; | |
typedef int element; |
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
import java.io.PrintWriter; | |
import java.util.Random; | |
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
/** | |
* |
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
// Dictionary.cpp : Defines the entry point for the console application. | |
// L.D.C.Lakmal | |
#include "stdafx.h" | |
#include <iostream> | |
#include <vector> | |
#include <fstream> | |
#include <string> | |
#include <sstream> | |
using namespace std; |