AEL/src/IO.java
2021-03-16 20:15:32 +01:00

28 lines
833 B
Java

import java.io.*;
public class IO {
public static String loadFile(File f) throws IOException {
BufferedInputStream in = new BufferedInputStream(new FileInputStream(f));
StringWriter out = new StringWriter();
int b;
while ((b=in.read()) != -1)
out.write(b);
out.flush();
out.close();
in.close();
return out.toString();
}
public static void writeFile(String string, String name) throws IOException {
File f = new File(name);
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(f));
StringReader in = new StringReader(string);
int b;
while ((b=in.read()) != -1)
out.write(b);
out.flush();
out.close();
in.close();
f.createNewFile();
}
}