Advertisement
Guest User

Untitled

a guest
May 11th, 2021
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. import java.io.File
  2. import java.time.LocalDateTime
  3. import java.time.format.DateTimeFormatter
  4.  
  5. fun main(args: Array<String>) {
  6.  
  7. val employerNamesList = readFileAsLinesUsingReadLinesForEmployerTxt(("C:\\Users\\Admin\\IdeaProjects\\untitled6\\out\\production\\untitled6\\employer.txt"))
  8.  
  9. for (lineInTxt in employerNamesList) {
  10. println(lineInTxt)
  11.  
  12.  
  13. val files =
  14. arrayOf("C:\\Users\\Admin\\IdeaProjects\\untitled6\\out\\production\\untitled6\\finaltemplates.txt")
  15. for (file in files) {
  16. val f = File(file)
  17. var text = f.readText()
  18. println(text)
  19. text = text.replaceFirst("<employer1>", lineInTxt)
  20.  
  21.  
  22. f.writeText(text)
  23. println(f.readText())
  24.  
  25. }
  26. }
  27.  
  28.  
  29.  
  30. val abc1 = readFileAsLinesUsingReadLines4(("C:\\Users\\Admin\\IdeaProjects\\untitled6\\out\\production\\untitled6\\jobtitles.txt"))
  31.  
  32. for (lineInTxt in abc1) {
  33. println(lineInTxt)
  34.  
  35.  
  36.  
  37. val current = LocalDateTime.now()
  38. val dayformatterday = DateTimeFormatter.ofPattern("dd")
  39. val dayformattermonth = DateTimeFormatter.ofPattern("MM")
  40. val dayformatteryear = DateTimeFormatter.ofPattern("YYYY")
  41.  
  42. val daystring = current.format(dayformatterday)
  43. val monthtring = current.format(dayformattermonth)
  44. val yearstring = current.format(dayformatteryear)
  45.  
  46. val files =
  47. arrayOf("C:\\Users\\Admin\\IdeaProjects\\untitled6\\out\\production\\untitled6\\finaltemplates.txt")
  48. for (file in files) {
  49. val f = File(file)
  50. var text = f.readText()
  51. println(text)
  52. text = text.replaceFirst("<jobtitle1>", lineInTxt)
  53. text = text.replace("<day>", daystring)
  54. text = text.replace("<month>", monthtring)
  55. text = text.replace("<year>", yearstring)
  56.  
  57. f.writeText(text)
  58. println(f.readText())
  59.  
  60. }
  61. }
  62.  
  63. }
  64.  
  65.  
  66. fun readFileAsLinesUsingReadLines4(fileName: String): List<String>{
  67.  
  68.  
  69. return File(fileName).readLines()
  70. }
  71.  
  72. fun readFileAsLinesUsingReadLinesForEmployerTxt(fileName: String): List<String>{
  73.  
  74.  
  75. return File(fileName).readLines()
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement