Skip to content

Instantly share code, notes, and snippets.

@ruseel
Created April 18, 2024 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruseel/862ba31cccd7ee60e12698a733d0d383 to your computer and use it in GitHub Desktop.
Save ruseel/862ba31cccd7ee60e12698a733d0d383 to your computer and use it in GitHub Desktop.
What file is raising MalformedInputException on slurp?
;; What file is raising MalformedInputException on slurp?
(use 'clojure.java.io)
(import 'java.nio.file.Files)
(import 'java.nio.file.Paths)
(import 'java.nio.charset.MalformedInputException)
(def directory? (memfn isDirectory))
(def name (memfn getName))
(def ->nbr #(Files/newBufferedReader (Paths/get (.toURI %))))
(defn malformed? [f] (try (slurp (->nbr f)) nil (catch MalformedInputException e f)))
(def files (file-seq (file ".")))
(transduce (comp
(filter directory?)
(filter (comp (partial re-seq #"resources|xyz") name))
(mapcat file-seq)
(filter (comp not directory?))
(filter malformed?))
conj
files)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment