delphi programming forums mysql charset mget recursive synonimos
free ventrilo servers hosting cs javascript delay python find in list
Back Forum New
abstract:

For example, if I insert the following text into the database:
The First Line
The Second Line
What gets outputed is:
The First Line The Second Line
Anyone know how to fix this?


Hello, I was curious if there is a certain method for extracting information of type Text from a database? The problem that I am having is that when I retrieve the data none of the newlines are being printed... For example, if I insert the following text into the database:
The First Line
The Second Line
What gets outputed is:
The First Line The Second Line
Anyone know how to fix this?

TOP

maybe use a newline char (\n)?

TOP

This sounds like an html issue.  Newlines don't display in your browser, you have to replace them with <br>.  Try something like:
dboutput = Pattern.compile( "/\n/" ).matcher( dboutput ).replaceAll( "<br>\n" ).toString();

TOP

In java, the result from a jdbc sql query is a result set which is read and processed something in a program like the one at:
http://www.quantumhyperspace.com/So...ExecuteSQL.java
(The source code was too long to post here)
The following example illustrates adding a new line character to each line read from a Buffered Reader which might work in your problem :
/*        Example.java
*/
import java.io.*;
public class Example{
        public static void main(String[] args){
                Example example = new Example();
                example.test();
        }
        public void test(){
                String someString = "la la la la la la la\rla la la la la la la\rla la la la la la la\r";
                String string = processLongString(someString);
                System.out.println(string);
        }
        public String processLongString(String s){
                String processedText = "";
                try{
                        StringReader sr = new StringReader(s);
                        BufferedReader br = new BufferedReader(sr);
                        String nextLine = "";
                        while ((nextLine = br.readLine()) != null){
                                processedText = processedText + nextLine + "\n";
                        }
                }catch(IOException ioe){
                        System.err.println("IOException: " + ioe.getMessage());
                }
                return processedText;
        }
}

TOP

abstract:

For example, if I insert the following text into the database:
The First Line
The Second Line
What gets outputed is:
The First Line The Second Line
Anyone know how to fix this?



  This sounds like an html issue. Newlines don't display in your browser, you have to replace them with <br>.
funny...i never saw any hint of html in the post...yet your point about "<br>" is correct.

TOP

Back Forum