-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrailingString.java
More file actions
40 lines (36 loc) · 871 Bytes
/
Copy pathTrailingString.java
File metadata and controls
40 lines (36 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.trailingstring;
import java.io.BufferedReader;
import java.io.FileReader;
/**
* TrailingString
* Used for matching trailing substring with a string.
*
* @author Harsh <girdharharsh01@gmail.com>
* @since 09/11/2015
*/
public class TrailingString {
public static void main(String[] args) {
try {
BufferedReader buffer = new BufferedReader(new FileReader(args[0]));
String line = null;
while ((line = buffer.readLine()) != null) {
line = line.trim();
if (!line.equals("")) {
String arr[] = line.split(",");
if (arr.length == 2) {
arr[0] = arr[0].trim();
arr[1] = arr[1].trim();
if(arr[0].endsWith(arr[1])) {
System.out.println(1);
} else {
System.out.println(0);
}
}
}
}
buffer.close();
} catch (Exception exception) {
exception.printStackTrace();
}
}
}