This file contains 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.util.ArrayList; | |
import java.util.List; | |
import java.util.Random; | |
import java.util.function.ToIntFunction; | |
import java.util.stream.Collectors; | |
import java.util.stream.IntStream; | |
import static java.lang.System.out; | |
public class FunctionalJava { |
This file contains 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 Encodings | |
{ | |
public static void main(String[] args) throws IOException | |
{ | |
FileInputStream inputStream = new FileInputStream("d:/data.txt"); | |
FileOutputStream outputStream = new FileOutputStream("d:/data.txt"); | |
SortedMap<String, Charset> charsets = Charset.availableCharsets();//список доступных кодировок | |
Charset currentCharset = Charset.defaultCharset();//узнать текущую кодировку |
This file contains 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
/* Проверка номера телефона | |
Метод checkTelNumber должен проверять, является ли аргумент telNumber валидным номером телефона. | |
Критерии валидности: | |
1) если номер начинается с '+', то он содержит 12 цифр | |
2) если номер начинается с цифры или открывающей скобки, то он содержит 10 цифр | |
3) может содержать 0-2 знаков '-', которые не могут идти подряд | |
4) может содержать 1 пару скобок '(' и ')' , причем если она есть, то она расположена левее знаков '-' | |
5) скобки внутри содержат четко 3 цифры | |
6) номер не содержит букв | |
7) номер заканчивается на цифру |
This file contains 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 org.apache.hadoop.conf.Configured; | |
import org.apache.hadoop.fs.Path; | |
import org.apache.hadoop.io.IntWritable; | |
import org.apache.hadoop.io.LongWritable; | |
import org.apache.hadoop.io.Text; | |
import org.apache.hadoop.mapreduce.Job; | |
import org.apache.hadoop.mapreduce.Mapper; | |
import org.apache.hadoop.mapreduce.Reducer; | |
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat; | |
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat; |
This file contains 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 Sort | |
{ | |
public static Map<Double, String> map = new TreeMap<Double, String>(Collections.reverseOrder()); | |
public static void main(String args[]) | |
{ | |
// create linked list object | |
LinkedList<Integer> list = new LinkedList<Integer>(); | |
// populate the list |
This file contains 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) { | |
Integer number = 255; | |
// Бинарный формат числа | |
String convert = Integer.toBinaryString(number); | |
System.out.println(convert); | |
// Восьмиричная форма | |
convert = Integer.toOctalString(number); |
This file contains 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 preparingDB; | |
import java.io.BufferedReader; | |
import java.io.FileReader; | |
import java.io.IOException; | |
import java.io.PrintWriter; | |
import java.util.*; | |
import java.util.concurrent.LinkedBlockingQueue; | |
/** |
This file contains 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.util.*; | |
import java.io.*; | |
class | |
{ | |
/************************ SOLUTION STARTS HERE ************************/ | |
private static void solve(FastScanner s1, PrintWriter out){ | |
This file contains 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
private static void write() throws FileNotFoundException, UnsupportedEncodingException { | |
PrintWriter printWriter = new PrintWriter(new OutputStreamWriter( | |
new FileOutputStream(file, true), "UTF-8")); | |
Scanner scanner = new Scanner(System.in); | |
String line; | |
while (true) { | |
line = scanner.nextLine(); | |
if ("--stop".equals(line)) break; | |
printWriter.println(line); | |
} |
This file contains 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
List<Person> persons = personsExtracter.getPersons(); | |
Collections.sort(persons, new AgeComparator()); | |
public class AgeComparator implements Comparator<Person> { | |
@Override | |
public int compare(Person o1, Person o2) { | |
Integer age1 = o1.getAge(); | |
Integer age2 = o2.getAge(); | |
return age1.compareTo(age2); | |
} |
OlderNewer