Announcement

Collapse

Mirth Connect 3.12.0 Released!

Mirth Connect 3.12.0 is now available as an appliance update and on our GitHub page. This release includes database performance improvements, improves visual HL7 representation, message pruning, keystore handling, PDF generation, community contributions, and fixes several security vulnerabilities. This release also contains many improvements to commercial extensions. See the release notes for the list of fixes and updates.

Download | See What's New | Upgrade Guide | Release Notes

For discussion on this release, see this thread.
See more
See less

FileUtil

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • FileUtil

    Can I use FileUtil to test if a file/directory exists, and also to move all files from a directory to another directory? What exactly are the supported methods for FileUtil?

  • #2
    Re:FileUtil

    FileUtil only has methods for writing/reading files. You'll have to write the Java/JavaScript function for moving files using the File API.
    Gerald Bortis | Chief Information Officer | Mirth Corporation

    Comment


    • #3
      Re:FileUtil

      This will get you there, I am trying to figure out how to do a FileExists prior to the copy because it errors if the file doesn't exist but hey, the pieces you need are here.
      if even creates the directory before copying the file.
      //
      var srcpath = "C://Temp//CarisDx_Mishra//IN//";
      var destpath = "C://Temp//CarisDx_Mishra//" + Yr + "//" + YrMnth + "//" ;
      var srcmsg = msg['TXA']['TXA.16']['TXA.16.1'].toString();
      channelMap.put('srcpath',srcpath)
      channelMap.put('destpath',destpath)
      channelMap.put('pdfname',srcmsg)
      //
      channelMap.put('FileUtil.Write', 'PDF Files Copied From ' + srcpath + srcmsg + ' -to- ' + destpath + srcmsg)
      // FileUtil.write('filename', append(true/false), stringData);
      FileUtil.write(destpath + srcmsg, false, FileUtil.read(srcpath + srcmsg));
      //var DeleteThisFile = Packages.java.io.File(srcpath + srcmsg);
      //DeleteThisFile['delete']();
      //

      Post edited by: M56969, at: 08/13/2008 16:26
      Mike Caldwell
      Alliance HealthCare - GE VAR
      Rocklin, CA
      Centricity PM/EMR Support - Developer - Network Engineer

      Comment


      • #4
        Re:FileUtil

        I know this is an old post, but I hope you periodically look here.
        Were you able to get this to work? Just the file copy part.
        I seem to be able to get it to copy something and call it the name I need it called, however it's not the original PDF. It changes the file structure somehow. The file size is correct, but it opens as a empty PDF. Maybe something to do with importing it as a string then re-encoding it??? I don't know. But I believe I am working on the same task you were trying to accomplish.
        If you have any different results I'd love to hear them.
        Thanks for what you have offered here. It has been a big help and place to start.
        Tom

        Comment


        • #5
          where can I find documentation for FileUtil?

          I would like to read text file into an array.

          Comment


          • #6
            Originally posted by jacek View Post
            where can I find documentation for FileUtil?
            Right here. However, it's deprecated, so you should be using Apache FileUtils instead.
            Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

            Nicholas Rupley
            Work: 949-237-6069
            Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


            - How do I foo?
            - You just bar.

            Comment


            • #7
              Thanks. I use Mirth Connect Server 2.1.

              Here is eror I get trrying to read FileUtil.readLines('C:\\test.xml'):

              Java class "com.mirth.connect.server.util.FileUtil" has no public instance field or method named "readLines"

              Comment


              • #8
                Originally posted by jacek View Post
                Thanks. I use Mirth Connect Server 2.1.

                Here is eror I get trrying to read FileUtil.readLines('C:\\test.xml'):

                Java class "com.mirth.connect.server.util.FileUtil" has no public instance field or method named "readLines"
                That's because you're using FileUtil rather than FileUtils...
                Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

                Nicholas Rupley
                Work: 949-237-6069
                Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


                - How do I foo?
                - You just bar.

                Comment

                Working...
                X