fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone {
  9.  
  10. public static void main (String[] args) throws java.lang.Exception {
  11.  
  12.  
  13. Integer trimSize = null;
  14.  
  15. while (in.ready()) {
  16.  
  17. String currentLine = in.readLine();
  18.  
  19. if (trimSize != null) {
  20. currentLine = currentLine.substring(0, trimSize);
  21. }
  22.  
  23. if (currentLine.startsWith("size:")) {
  24. trimSize = Integer.parseInt(currentLine.substring(5));
  25. }
  26. else {
  27. trimSize = null;
  28. }
  29.  
  30. System.out.println(currentLine);
  31.  
  32. }
  33.  
  34. }
  35.  
  36. }
Success #stdin #stdout 0.07s 380224KB
stdin
qqqqqqqqqqq
wwwwwwwwwwww
eeeeeeeee
size:10
текст у которого нужно отрезать 400 символов...
rrrrrrr
tttttt
yyyyyyyyy
stdout
qqqqqqqqqqq
wwwwwwwwwwww
eeeeeeeee
size:10
текст у ко
rrrrrrr
tttttt
yyyyyyyyy