Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package handler;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.IOException;
- import java.io.PrintWriter;
- public class LogWriter {
- public String pathName = "//logs//log.txt";
- public File logFile;
- public PrintWriter logWriter;
- public LogWriter() throws FileNotFoundException
- {
- logFile = new File(pathName);
- //logWriter = new PrintWriter(logFile);
- }
- /**
- * will create a new log file if none by that name is created
- * @return success if a new log was created. Failure if not
- * @throws IOException
- */
- public boolean createLogFile() throws IOException
- {
- if(logFile.exists()) {
- logFile.delete();
- createLogFile();
- }
- else{
- logFile = new File(pathName);
- logFile.mkdirs();
- if(logFile.createNewFile()) System.out.println(">Console: New log file created"); else System.out.println(">Console: Log file already exists");
- return true;
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement