forked from srinathr91/TestJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRevRecurStr.java
More file actions
31 lines (25 loc) · 833 Bytes
/
RevRecurStr.java
File metadata and controls
31 lines (25 loc) · 833 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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class RevRecurStr {
public static String reverse(String str){
if(str==null||str.length()==1){
return str;
}
return reverse(str.substring(1)+str.charAt(0));
}
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
//BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
InputStreamReader input=new InputStreamReader(System.in);
StringBuilder st = new StringBuilder();
char[] b = new char[2048]; // the max limit.
int read;
while( ((read = input.read(b, 0, 2048)) != -1)&&read!='\n') {
st.append(new String(b, 0, read));
}
input.close();
System.out.println(st.toString());
}
}