4 Replies Latest reply on Sep 12, 2009 4:31 PM by 843789

    Writing an platform independent text file through JAVA

    843789
      I have written a file writing programm through java its working but its
      settings(tab spacing and spaces) are get change as I open that file on different OS like Windows and Centos 5.
      So how to overcome that problem?so that I can get the well formatted file under any OS(platform)......

      Please help me out.....................
        • 1. Re: Writing an platform independent text file through JAVA
          843789
          As far as my Knowledge goes, you are bound by the rules of the os you are running on. A solution could be that you search for specific characters like end of file or end of line in the file and translate those to another character But before you know it you are reinventing pdf or other oss formats. perhaps writing to xml is a solution?
          • 2. Re: Writing an platform independent text file through JAVA
            843789
            what exactly is the problem you are having?

            is it lining up columns of text. If so then it is probably a font issue and not an Operating system one.

            Do you have a small example?
            • 3. Re: Writing an platform independent text file through JAVA
              3004
              kkcnkc wrote:
              I have written a file writing programm through java its working but its
              settings(tab spacing and spaces) are get change as I open that file on different OS like Windows and Centos 5.
              A text file does not have tab/space settings. It doesn't have anything but the text you put into it. If tabs are showing up differently that's because the programs you're using to view the file with--notepad, vi, etc.--have different settings for how to treat tabs. It's not an OS issue. The only think you can do is change the settings used by the programs reading the files.
              • 4. Re: Writing an platform independent text file through JAVA
                843789
                jverd wrote:
                kkcnkc wrote:
                I have written a file writing programm through java its working but its
                settings(tab spacing and spaces) are get change as I open that file on different OS like Windows and Centos 5.
                The only think you can do is change the settings used by the programs reading the files.
                Or, as many people do in this situation, just use spaces instead of tab characters.