
http://www.csse.monash.edu.au/~aland/ALJ/article1Resources.html
I almost wish I hadn't gone down that rabbit-hole — and yet — and yet — it's rather curious, you know, this sort of life!
String input = "something";
String regex="your_reg_ex";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(input);
if (m.find()) { //5. if found, the matched portion will be available at m.group() String found = m.group(); // do whatever u like }
Look-behind group does not have an obvious maximum length near index ..
1 2 String regularExp = "(?<=A).*?(?=A)"; 3 4 String input = "fjkl;pokjhA123ss456Apghkit"; 5 6 Pattern pattern = Pattern.compile(regularExp); 7 8 Matcher matcher = pattern.matcher(input); 9 10 if(matcher.find()) 11 { 12 String parsedData = matcher.group(); 13 System.out.println(" Output ->"+parsedData); 14 } 15
When given an HttpServletRequest, the ActionMapper may return null if no action invocation request matches, or it may return an ActionMapping that describes an action invocation for the framework to try.
If the ActionMapper determines that an Action should be invoked, the FilterDispatcher delegates control to the ActionProxy.
ScpClient client = ssh.openScpClient();
// Open the SCP channel
String localFile = "localPath";
String remoteFile = "remotePath";
//
//get method signature
//public void get(java.lang.String localFile,
// java.lang.String remoteFile,
// boolean recursive,
// FileTransferProgress progress)
// throws SshException,
// ChannelOpenException
//
client.get(localFile,remoteFile,true);
1
2 String userName = "someuser";
3 String password = "somepwd";
4
5 String host = "host_ip";
6 int port = 22;
7
8 String destinationPath = "<your_dest>";
9 String sourcePath = "<your_src>";
10
11 SshClient ssh = new SshClient();
12
13 try{
14 ssh.connect(host, port);
15
16 // Authenticate
17 PasswordAuthenticationClient passwordAuthenticationClient =
18 new PasswordAuthenticationClient();
19
20 passwordAuthenticationClient.setUsername(userName);
21 passwordAuthenticationClient.setPassword(password);
22
23 int result = ssh.authenticate(passwordAuthenticationClient);
24 if(result != AuthenticationProtocolState.COMPLETE){
25
26 throw new FTPException("Login to " + host + ":"
27 + port + " " + userName + "/" + password + " failed");
28
29 }
30
31 // Open the SFTP channel
32 SftpClient client = ssh.openSftpClient();
33 //change local directory where file would be copied
34 client.lcd(destination);
35 // download file
36 client.get(sourceFilePath);
37
38 client.quit();
39 ssh.disconnect();
40
41 }
42 catch(IOException e)
43 {
44
45 // file transfer failed
46 e.printStackTrace();
47 }
// Step 1: Create an instance of com.lowagie.text.Document:
Document document = new Document();
//Step 2: Create a Writer (for instance com.lowagie.text.pdf.PdfWriter)
//that listens to this document and
//writes the document to the OutputStream of your choice:
PdfWriter.getInstance(document, new FileOutputStream("HelloWorld.pdf"));
//Step 3: Open the document:
document.open();
//Step 4: Add content to the document:
document.add(new Paragraph("Hello World"));
//Step 5: Closes the document:
document.close();