public static void loadChannels(Arisu ar) throws Exception { File file = new File("channels.txt"); if (!file.exists()) { file.createNewFile(); } BufferedReader read = new BufferedReader(new FileReader(file)); String line; while ((line = read.readLine()) != null) { if (!ar.channels.contains(line)) { if (!line.startsWith("!") && !line.isEmpty()) { ar.channels.add(line); ar.joinChannel(line); Files.loadlog(ar, line); } } } System.out.println("loaded channels.txt"); System.out.println("channels: " + ar.channels.toString()); }
public static void savelog(Arisu ar, String channel, String user, String msg) { try { Files.loadlog(ar, channel); File dir = new File("logs"); if (!dir.exists()) { dir.mkdir(); } File file = new File(dir + "/" + channel + ".log"); FileWriter d = new FileWriter(file); StringBuilder f = new StringBuilder(); for (int i = 0; i < ar.log.size(); i++) { f.append(ar.log.get(i).toString()); f.append("\n"); } f.append(msg); f.append("\n"); d.flush(); d.write(f.toString()); d.close(); } catch (Exception ex) { System.out.println("savelog error: " + ex); } }