Results 1 to 9 of 9
Like Tree1Likes
  • 1 Post By Norm

Thread: Text file format lost in AIX

  1. #1
    rak
    rak is offline Member
    Join Date
    Jul 2011
    Posts
    4
    Rep Power
    0

    Default Text file format lost in AIX

    I am using RAD in Windows Environment I developed application which will throw the .txt file to the user(basically user can download a file from the server).

    * This works fine in windows environment.
    * But when I move the code to AIX environment then the user download the file but the alignment is messed up.

    The code goes like this....
    String filePath = System.getProperty("BIOP_FILE_GEN_PATH");
    file = new File(filePath);
    fis = new FileInputStream( file );
    int len = fis.available();
    byte byteArray[] = new byte[len];
    fis.read(byteArray);
    response.setContentType( "application/text" );
    response.setHeader("Content-Disposition", "attachment; filename=\"" + input.getID_NAME_FILE() +"\"");
    response.setContentLength( len );
    response.getOutputStream().write( byteArray, 0, len );
    response.getOutputStream().flush();
    response.getOutputStream().close();

    Anybody have any idea?
    Thanks in advance

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,589
    Rep Power
    23

    Default

    the alignment is messed up.
    Can you explain what the "alignment" of a text file is?
    How do you see that it is not aligned?
    Are you using tabs? The spacing for a tab is user/app settable.

  3. #3
    rak
    rak is offline Member
    Join Date
    Jul 2011
    Posts
    4
    Rep Power
    0

    Default

    Thanks for your reply.

    The original file looks like this...

    ************************************************** *********************
    * NAME * FOR PERIOD: 06/30/11 - 07/06/11 *
    * JERSEY * ABC *
    ************************************************** *********************


    Becomes like this when it comes to client ...


    ************************************************** ********************* * NAME * FOR PERIOD: 06/30/11 - 07/06/11 *
    * JERSEY * ABC * ************************************************** ************



    This file I got it from one of my vendor and they used tabs for formatting.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,589
    Rep Power
    23

    Default

    Looks like line ends and tabbing problem.
    Tabbing can vary from one program to another. Better to not use them unless you know what the tab setting are in the program that will display the data.
    Seems there are several different line ends. Some take CR, some take LF and some take both.
    I guess you need to know what your target machine is using.
    rak likes this.

  5. #5
    rak
    rak is offline Member
    Join Date
    Jul 2011
    Posts
    4
    Rep Power
    0

    Default

    My target users are windows(IE8) but my server is AIX.

    But this works fine in windows region(Local RAD & IE8), it fails only I move the code and file to AIX server.

    If I change the file extension from .txt to .doc then it retains the format. But the end user has to change the Page Setup to "Landscape" and print in Legal Paper, then only the end user can able to see the full content.

    Is there anyway in which I can force the document to be viewed in "Landscape"

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,589
    Rep Power
    23

    Default

    I don' think there is any formatting information in text file other than things like tabs and lineends.

  7. #7
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,005
    Blog Entries
    7
    Rep Power
    20

    Default

    My guess is that it's a \r\n (MS Windows) versus \n (Unix etc.) thingy.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default

    Quite.
    How is that file generated?
    That's the key, since that code up there is simply streaming an existing file back to the client.

  9. #9
    rak
    rak is offline Member
    Join Date
    Jul 2011
    Posts
    4
    Rep Power
    0

    Default

    Thanks guys for all your efforts.

    I simply provided this solution...

    I zipped the text file and moved to the server when the client download the file then the formatting is retained.

    Thanks once again!!!

Similar Threads

  1. Trying to get correct text format in .txt file
    By patriotsfan in forum New To Java
    Replies: 14
    Last Post: 06-06-2011, 02:29 AM
  2. Text format in JTextArea
    By goodlily in forum AWT / Swing
    Replies: 4
    Last Post: 04-10-2011, 11:57 PM
  3. Text/String format..??
    By Neullson in forum New To Java
    Replies: 14
    Last Post: 07-23-2010, 08:51 AM
  4. Format some text with Java
    By vampire in forum New To Java
    Replies: 0
    Last Post: 02-18-2010, 06:45 AM
  5. Text Format Error
    By MrFish in forum New To Java
    Replies: 2
    Last Post: 01-13-2010, 01:06 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •