Char array not creating String Object

Hi,

I am getting a char[] after executing a DB Stored Proc from Sybase DB . But the value returned is Cha [] instead of String. I understand that string and char[] are same . but that is not the case . When I try to display the string in JTextarea it does not honor the \n . Slso the spilt method of String too does not work.

Can some one help me to convert this char[] to pure String object when I can apply all the String methods like spilt() , index of etc

Regards

Java Knight

[512 byte] By [Java_Knight_123a] at [2007-11-27 10:45:16]
# 1

> I understand that string and

> char[] are same .

They're not.

> Can some one help me to convert this char[] to pure

> String object when I can apply all the String methods

> like spilt()

String str = new String(theCharArray);

jverda at 2007-7-28 20:12:00 > top of Java-index,Java Essentials,Java Programming...
# 2

All you'd have had to do is look at the docs for String to find a method or constructor that takes in a char[] and produces a String.

jverda at 2007-7-28 20:12:00 > top of Java-index,Java Essentials,Java Programming...
# 3

I tried

String str = new String (char[])

But this is too not working .

Java_Knight_123a at 2007-7-28 20:12:00 > top of Java-index,Java Essentials,Java Programming...
# 4

What is different between your code and the example provided by jverd in reply #1?

floundera at 2007-7-28 20:12:00 > top of Java-index,Java Essentials,Java Programming...
# 5

> But this is too not working .

Not working HOW?

This is not a seance.

ejpa at 2007-7-28 20:12:00 > top of Java-index,Java Essentials,Java Programming...
# 6

> > But this is too not working .

>

> Not working HOW?

>

> This is not a seance.

It's amazing the number of dolts who post "it's not working" and think we will immediately know what the fuck is wrong.

floundera at 2007-7-28 20:12:00 > top of Java-index,Java Essentials,Java Programming...
# 7

> I tried

>

> String str = new String (char[])

>

> But this is too not working .

Is this the first time you've ever invoked a constructor or method that takes arguments?

jverda at 2007-7-28 20:12:00 > top of Java-index,Java Essentials,Java Programming...
# 8

> When I

> try to display the string in JTextarea it does not honor the \n .

It does honor it. On some systems like Windows, \n just isn't a line break (which would be \r\n). That's what the line.separator System property is for.

> Slso the spilt method of String too does not work.

It does work.

CeciNEstPasUnProgrammeura at 2007-7-28 20:12:00 > top of Java-index,Java Essentials,Java Programming...
# 9

Java Knight, please use your favourite search engine to search for "how to ask questions the smart way" (or something similar), read and learn, and then come back here and rephrase your question and provide us with the information we need to answer. It'll all work out much better that way.

OleVVa at 2007-7-28 20:12:00 > top of Java-index,Java Essentials,Java Programming...