How to check System Preference in Java
long startTime=System.currentTimeMillis();
long costTime = System.currentTimeMillis() - startTime;
* in spring you can use api whcih calculate in nano seconds
How to replace single quote '
public static String replace(String orig, String from, String to)
{
int start = orig.indexOf(from);
if(start == -1)
return orig;
int lf = from.length();
char[] origChars = orig.toCharArray();
StringBuffer buffer = new StringBuffer();
int copyFrom = 0;
while(start != -1)
{
buffer.append(origChars, copyFrom, start - copyFrom);
buffer.append(to);
copyFrom = start + lf;
start = orig.indexOf(from, copyFrom);
}
buffer.append(origChars, copyFrom, origChars.length - copyFrom);
return buffer.toString();
}
Logout:
private String logout(HttpServletRequest req, HttpServletResponse resp)
{
String logoutURL = "http://" + req.getServerName() + ":" + req.getServerPort() + "/abc";
if(PasswordProtected)
{
logoutURL = logout_URL;
}
HttpSession ses = req.getSession();
if(ses == null)
{
return logoutURLforme;
}
ses.invalidate();
return logoutURLforme;
} |