Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.BufferedWriter;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileReader;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.io.PrintWriter;
- import java.util.Scanner;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- public class taskBckg {
- // Returns true if file exists
- public static boolean checkForFile() throws IOException {
- File f = new File("tasks.txt");
- if (!f.exists()) {
- // Create the file
- createTasksFile();
- } else {
- return true;
- }
- return false;
- }
- public void openWebpage(String address) {
- try
- {
- Process p=Runtime.getRuntime().exec("cmd /c start "+ address);
- }
- catch(IOException e1) {
- System.out.println(e1);
- }
- }
- // Returns true if errors still exist
- @SuppressWarnings("null")
- public static String[] runDiagnostics() throws IOException {
- gui gui1 = new gui();
- gui1.setCurStatus("Now running diagnostics... Please wait!");
- int i = 0;
- int errorsI = 0;
- File f = new File("tasks.txt");
- String[] errors = { "", "", "", "", "" };
- // try to create the file three times
- do {
- f.createNewFile();
- i++;
- } while (!f.exists() && i < 3);
- // if the file creating was still unsuccessful, give out an error
- if (!f.exists()) {
- errors[errorsI] = "Error creating the file!";
- errorsI++;
- }
- if (!f.canRead()) {
- errors[errorsI] = "Error reading the file!";
- errorsI++;
- }
- if (!f.canWrite()) {
- errors[errorsI] = "Error writing to the file!";
- errorsI++;
- }
- return errors;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement