Guest User

Untitled

a guest
Dec 11th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. package kkdprojekt3;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.FileNotFoundException;
  5. import java.io.FileReader;
  6. import java.io.IOException;
  7. import java.util.logging.Level;
  8. import java.util.logging.Logger;
  9.  
  10. public class Main {
  11.  
  12. public static void main(String[] args) {
  13. String path1 = "in.txt";
  14.  
  15. try {
  16. BufferedReader in = new BufferedReader(new FileReader(path1));
  17. //BufferedWriter out = new BufferedWriter(new FileWriter(path2));
  18. String line = null;
  19. while (in.ready()) {
  20. try {
  21. line = in.readLine();
  22. } catch (IOException ex) {
  23. Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
  24. }
  25. char c = line.charAt(0);
  26. char d = 0;
  27. //int seria = 0;
  28. String s = "";
  29. s += c;
  30. for (int i = 1; i < line.length(); i++) {
  31. d = line.charAt(i);
  32. //System.out.print(c + "-" + d + " ");
  33.  
  34. if (c == d) {
  35. s += c;
  36. if (s.length() > 3) {
  37. seria++;
  38. System.out.print(seria + ":" + d);
  39. }
  40. } else {
  41. System.out.print(s);
  42. s = null;
  43. c = d;
  44. //i -= 1;
  45. /*if (seria > 0) {
  46.  
  47. }*/
  48.  
  49. //seria = 0;
  50. }
  51. }
  52. }
  53. } catch (FileNotFoundException ex) {
  54. Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
  55. } catch (IOException ex) {
  56. Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
  57. }
  58. }
  59. }
Add Comment
Please, Sign In to add comment