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
| package com.company.ex; | |
| import java.io.BufferedReader; | |
| import java.io.IOException; | |
| import java.io.InputStreamReader; | |
| import java.util.ArrayList; | |
| /** | |
| * Created by IDEA on 26/01/15. | |
| */ |
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
| public Rect(int x1, int y1, int x2, int y2) { | |
| this.x1 = min(x1, x2); | |
| this.y1 = min(y1, y2); | |
| this.x2 = max(x1, x2); | |
| this.y2 = max(y1, y2); | |
| } |
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
| @Override | |
| public boolean equals(Object o) { | |
| if(o == this) return true; | |
| if(!(o instanceof IntList)) return false; | |
| IntList that = (IntList) o; | |
| if(this.size != that.size) return false; | |
| for(int i = 0; i < this.size; i++) { | |
| if(this.data[i] != that.data[i]) return false; | |
| } | |
| return true; |
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
| /** | |
| * Created by IDEA on 27/01/15. | |
| */ | |
| public interface Tokenizer { | |
| public static final int EOF = -1; | |
| public static final int SPACE = -2; | |
| public static final int NUMBER = -3; | |
| public static final int WORD = -4; | |
| public static final int KEYWORD = -5; | |
| public static final int TEXT = -6; |
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
| package com.company; | |
| import java.io.IOException; | |
| import java.util.Map; | |
| /** | |
| * Created by IDEA on 27/01/15. | |
| */ | |
| public abstract class AbstractTokenizer implements Tokenizer { | |
| boolean skipSpaces; |
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
| public class Main { | |
| public static void main(String[] args) { | |
| char[] a = "0123456789".toCharArray(); | |
| // create a string from a char array | |
| String x = new String(a, 2, 3); | |
| System.out.println(x); | |
| } | |
| } |
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
| package com.company; | |
| import java.io.IOException; | |
| import java.util.HashMap; | |
| import java.util.Map; | |
| /** | |
| * Created by IDEA on 27/01/15. | |
| */ | |
| public abstract class AbstractTokenizer implements Tokenizer { |
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
| public static int[] concatArrays(int[] a1, int[] a2) { | |
| int n1 = a1.length; | |
| int n2 = a2.length; | |
| if(n1 == 0) return a2; | |
| if(n2 == 0) return a1; | |
| int n = n1 + n2; | |
| int counter = 0; | |
| int[] result = new int[n]; | |
| for(; counter < n1; counter++) { |
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
| public static void copy(String from_name, String to_name) throws IOException { | |
| File to_file = new File(to_name) | |
| File from_file = new File(from_name); | |
| if(!from_file.exists()) throw new IllegalArgumentException("not such file: " + from_name); | |
| if(!from_file.isFile()) throw new IllegalArgumentException("not a regular file: " + from_name); | |
| if(!from_file.canRead()) throw new IllegalArgumentException("not readable: " + from_name); | |
| if(to_file.isDirectory()) to_file = new File(to_file, from_file.getName()); | |
| if(to_file.exists()) { | |
| if(!to_file.canWrite()) { | |
| System.out.print("Overwrite existing file? (y/N)"); |
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
| package je3.io; | |
| import java.io.IOException; | |
| import java.io.RandomAccessFile; | |
| /** | |
| * Created by IDEA on 29/01/15. | |
| */ | |
| public class Tail { | |
| public static String[] tailLines(String filename) throws IOException { |