ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

How to import txt file or html file on IFS to web app without losing alignment

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

  • How to import txt file or html file on IFS to web app without losing alignment

    Hi All,

    We have a web app. in which we show some spooled files.
    These spooled files have fixed border lines.

    Using a convert spooled file to text or html file on ifs give a goor result when opening these files from the ifs directly

    But when I want to read these files in our web app with the bufferedReader class, the border is not fixed any more, how can I assure that in the web app I have the same results as I have when displaying the spooled file and its converted ifs file directly ?

    Here the java code :
    IFSFile file = new IFSFile(as400, ifsPath);
    BufferedReader d = new BufferedReader(new IFSFileReader(file));

    String data = "";
    while ((data = d.readLine()) != null) {
    varSpool = varSpool + data + "\n";
    }
    // Close the reader.
    d.close();


    Thanks for your help

  • #2
    Re: How to import txt file or html file on IFS to web app without losing alignment

    A quick look on the net via google:

    -> from


    see Scott Klement
    10-16-2006, 04:27 PM
    I wrote a quick proof of concept program that seems to work okay.

    -> from


    // Demonstrates using the AS400DetailsPane to display
    // AS/400 Spooled files for a given user


    -> from



    bshiels Posts:2 Registered: 11/11/98

    Re: Reading Spool files from AS400 through JAVA Applications 17-jan-2003 6:15 (reply 5 of 5)


    If you were expecting the spool file to be translated to ASCII with carriage returns, line feeds, and form feeds, here is the magical piece of code:

    SpooledFile splf = new SpooledFile(sys, splfName, splfNum, jobName, jobUser, jobNum);
    PrintParameterList pl = new PrintParameterList();
    pl.setParameter(SpooledFile.ATTR_MFGTYPE, "*WSCST");
    pl.setParameter(SpooledFile.ATTR_WORKSTATION_CUST_ OBJECT, "/QSYS.LIB/QWPDEFAULT.WSCST");
    InputStream in = splf.getTransformedInputStream(pl);

    For reasons not immediately clear to me, the first character in the file appears to be a null byte (hex 0). I also believe that CRs and LFs only appear as needed to return to the beginning of the line (CR) and the feed one line (LF). It is permissible for example to have <data><CR><LF><LF><LF> (i.e. feed three lines). I also assume that <data><CR><data><CR><LF> would result in overprinting (missing line feed). I have even seen <data><CR><CR>, and I assume the second CR should be ignored.


    I have not exhaustively tested these scenarios, but from some of the problems we've had, the above description seems like a reasonable way to think about the data stream

    *

    Comment


    • #3
      Re: How to import txt file or html file on IFS to web app without losing alignment

      Why would you use 132 and not 133 when the spool file is 132.

      If you use 133 then you keep all the control characters so not to loose the line and form spacing (forms control).

      -> from

      Step 1: Create a flat file that has a record length of 132 (most spool files have a width of 132). CRTPF FILE(FLATFILE) RCDLEN(132) Step 2: ...

      Comment


      • #4
        Re: How to import txt file or html file on IFS to web app without losing alignment

        I have tried already several posibilities but the alignment is not correct


        See the files include in the zip file :
        The file spooledFileNotAligned displays the way the spooled file is displayed in our web app (with the coding of your last link)

        The file spooledFilesAsonAS400 displays the spooled file on the as400 system itself.

        As you see the second has a correct alignment at the end of every lign !!!



        So it seems that the pixels taken for one space is the reason ...
        Attached Files

        Comment


        • #5
          Re: How to import txt file or html file on IFS to web app without losing alignment

          Can it be that the reason for this is the buffer in which the data is collected at the Java side?

          That this is not the correct object to show the spooled file as is ...

          Comment

          Working...
          X