List of usage examples for java.lang Integer parseInt
public static int parseInt(String s) throws NumberFormatException
From source file:Main.java
public static void main(String[] args) { List<String> stringList = Arrays.asList("1", "2", "3", "4", "5"); stringList.stream().mapToInt(n -> Integer.parseInt(n)).filter(n -> n % 2 == 0).forEach(System.out::println); }
From source file:Main.java
public static void main(String[] args) { Function<Integer, String> converter = (i) -> Integer.toString(i); Function<String, Integer> reverse = (s) -> Integer.parseInt(s); System.out.println(converter.apply(3).length()); System.out.println(converter.andThen(reverse).apply(30).byteValue()); }
From source file:Main.java
public static void main(String[] args) { Function<Integer, String> converter = (i) -> Integer.toString(i); Function<String, Integer> reverse = (s) -> Integer.parseInt(s); System.out.println(converter.apply(3).length()); System.out.println(converter.compose(reverse).apply("30").length()); }
From source file:Main.java
public static void main(String[] args) throws Exception { ServerSocket ssock = new ServerSocket(Integer.parseInt(args[0])); Socket sock = ssock.accept(); GZIPInputStream zip = new GZIPInputStream(sock.getInputStream()); while (true) { int c;/*from w w w . jav a 2s . c om*/ c = zip.read(); if (c == -1) break; System.out.print((char) c); } }
From source file:Main.java
public static void main(String[] args) { Stream<String> s = Stream.of("1", "2", "3"); int o = s.collect(Collectors.summingInt(n -> Integer.parseInt(n))); System.out.println(o);/*from w w w . ja v a 2s .co m*/ }
From source file:ServerSocketDemo.java
public static void main(String args[]) throws Exception { int port = Integer.parseInt(args[0]); ServerSocket ss = new ServerSocket(port); while (true) { Socket s = ss.accept();//from w w w. j a v a 2s. c o m OutputStream os = s.getOutputStream(); DataOutputStream dos = new DataOutputStream(os); dos.writeInt(1); s.close(); } }
From source file:Main.java
public static void main(String[] args) { Stream<String> s = Stream.of("1", "2", "3"); double o = s.collect(Collectors.averagingInt(n -> Integer.parseInt(n))); System.out.println(o);/*from w ww .j ava 2 s. c o m*/ }
From source file:Main.java
License:asdf
public static void main(String args[]) throws Exception { InetAddress ia = InetAddress.getByName(args[0]); int port = Integer.parseInt(args[1]); DatagramSocket ds = new DatagramSocket(); while (true) { String s = "asdf"; byte buffer[] = s.getBytes(); DatagramPacket dp = new DatagramPacket(buffer, buffer.length, ia, port); ds.send(dp);/*ww w. j ava 2 s.c o m*/ } }
From source file:Main.java
public static void main(String[] args) throws Exception { Socket sock = new Socket(args[0], Integer.parseInt(args[1])); GZIPOutputStream zip = new GZIPOutputStream(sock.getOutputStream()); String line;/* w w w. j a va2s .c om*/ BufferedReader bis = new BufferedReader(new FileReader(args[2])); while (true) { line = bis.readLine(); if (line == null) break; line = line + "\n"; zip.write(line.getBytes(), 0, line.length()); } zip.finish(); zip.close(); sock.close(); }
From source file:Main.java
public static void main(String[] args) { List<String> stringList = Arrays.asList("1.2", "2.2", "3", "4", "5"); stringList.stream().flatMapToInt(n -> IntStream.of(Integer.parseInt(n))).forEach(System.out::println); }