Angular Tutorial: Getting Started With Angular
Welcome to Angular tutorials, in this tutorial i will cover all the topics of angular and after this tutorial you will be able to write the code of angular.
So lets start the tutorial step by step.
package com.string.codebyakram;
import java.util.HashMap;
public class NonReapingCahr {
public static void main(String[] args) {
String string = "hello";
System.out.println(findNonReapingCahr(string));
}
public static char findNonReapingCahr(String string) {
HashMap< character > countChar = new HashMap<>();
for (int i = 0; i < string.length(); i++) {
int count = countChar.get(string.charAt(i)) == null ? 1 : countChar.get(string.charAt(i)) + 1;
countChar.put(string.charAt(i), count);
}
for (int i = 0; i < string.length(); i++) {
if (countChar.get(string.charAt(i)) == 1) {
return string.charAt(i);
}
}
return '\0';
}
}
log4j.rootLogger=TRACE, stdout
log4j.appender.dataLogs=org.apache.log4j.FileAppender
log4j.appender.dataLogs.File=logs/logFile1.log
log4j.appender.dataLogs.layout=org.apache.log4j.PatternLayout
log4j.appender.dataLogs.layout.ConversionPattern=%d [%24F:%t:%L] - %m%n
log4j.appender.reportsLog=org.apache.log4j.FileAppender
log4j.appender.reportsLog.File=logs/logFile2.log
log4j.appender.reportsLog.layout=org.apache.log4j.PatternLayout
log4j.appender.reportsLog.layout.ConversionPattern=%d [%24F:%t:%L] - %m%n
log4j.category.dataLogger=TRACE, dataLogs
log4j.additivity.debugLogger=false
log4j.category.reportsLogger=DEBUG, reportsLog
log4j.additivity.reportsLogger=false
Then configure the loggers in the code accordingly as shown below:static final Logger debugLog = Logger.getLogger("dataLogger");
static final Logger resultLog = Logger.getLogger("reportsLogger");
package com.avaya.deletelogs;
import java.io.File;
import java.io.FilenameFilter;
import java.util.Arrays;
import java.util.List;
public class DeleteLogs {
private String baseDir = "/opt/java/IVRLog";
private int daysBack = 4;
public void invokeProcess() {
getFolders();
}
public void getFolders() {
try {
File file = new File(baseDir);
String[] directories = file.list(new FilenameFilter() {
public boolean accept(File current, String name) {
return new File(current, name).isDirectory();
}
});
deleteFiles(daysBack, baseDir, Arrays.asList(directories));
} catch (Exception e) {
System.out.println(e);
}
}
public void deleteFiles(int daysBack, String dirWay, List< string> directories) {
for (String dir : directories) {
deleteFilesOlderThanNdays(daysBack, dir);
}
}
public void deleteFilesOlderThanNdays(int daysBack, String dirWay) {
File directory = new File(baseDir + "/" + dirWay);
if (directory.exists()) {
File[] listFiles = directory.listFiles();
long purgeTime = System.currentTimeMillis() - (daysBack * 24 * 60 * 60 * 1000);
for (File listFile : listFiles) {
try {
if (listFile.isFile()) {
if (listFile.lastModified() < purgeTime) {
if (!listFile.delete()) {
System.err.println("Unable to delete file: " + listFile);
}
}
} else {
continue;
}
} catch (Exception e) {
System.out.println(e);
}
}
}
}
}