My fault. Why didn't I think about this (I have spent 4 hours to figure it out). It works now.
Thanks.
Adam Taft <[EMAIL PROTECTED]> wrote:
Adam Taft <[EMAIL PROTECTED]> wrote:
You're not comparing strings with the == (equality) operator, are you??
You'll always get false this way since you're comparing two different
string objects (with the same string value).
Try, the equals() method on your strings. Ie.
System.out.println(mediaData.getMediaName().equals(name));
Indra Syafruddin wrote:
> I tried to compare two String, one comes from parameter that is sent via
> xmlrpc, one comes from arraylist data.
>
> Both String have exactly same data. But why the comparation value return
> false??
>
> import java.util.*;
>
> public class ListMedia {
>
> private MediaData mediaData;
>
> private MediaData[] listData;
>
> private List list = new ArrayList();
>
> public ListMedia() {
> this.createMediaList();
> mediaData = getMediaData("test.avi");
> System.out.println(mediaData.getMediaName());
> }
>
> private void createMediaList() {
> mediaData = new MediaData("Nyoba.avi", "c:/fans/Nyoba.avi", "video",
> "audio");
> list.add(mediaData);
>
> mediaData = new MediaData("test.avi", "c:/fans/test.avi", "videoTest",
> "audioTest");
> list.add(mediaData);
>
> mediaData = new MediaData("testjuga.avi", "c:/fans/test.avi",
> "videoTest", "audioTest");
> list.add(mediaData);
> }
>
> public void addMediaList(String name, String url, String video, String
> audio) {
> mediaData = new MediaData(name, url, video, audio);
> list.add(mediaData);
> }
>
> public void removeMediaList(Iterator i) {
> i.remove();
> }
>
> public MediaData getMediaData(String name) {
> System.out.println("name = " + name);
> ListIterator i = list.listIterator();
> for (int no = 0; i.hasNext();) {
> mediaData = (MediaData) i.next();
> System.out.println(mediaData.getMediaName() + " = " + name);
> System.out.println(mediaData.getMediaName() == name);
> if (mediaData.getMediaName() == name) {
> System.out.println("found");
> break;
> }
>
> // mediaData = null;
> }
>
> System.out.println(mediaData.getMediaName());
> return mediaData;
> }
>
> public static void main(String[] args) {
> new ListMedia();
>
> }
> }
>
> Here's the output when I run server:
>
> Starting server on port 1234
>
> server running
>
> name = test.avi
>
> Nyoba.avi = test.avi
>
> false
>
> test.avi = test.avi
>
> true
>
> found
>
> test.avi
>
> test.avi
>
> And here's the output when I create request :
>
> name = test.avi
>
> Nyoba.avi = test.avi
>
> false
>
> test.avi = test.avi // Why it is false???
>
> false
>
> testjuga.avi = test.avi
>
> false
>
> testjuga.avi
>
>
>
> Anyone knows why it can happen??
>
> thanks
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
