Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to set data from UTF8 to bean file.java

 
Sharon Wong
Ranch Hand
Posts: 35
IBM DB2 Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi Team,



Please kindly advice hot to set String UTF 8 to bean file (newsBean.setsContent_elasticNews(UTF8))?

I always get the newsBean.setsContent_elasticNews is null pointer, althought UTF8 have value.

For noted:

println for UTF8 is as below

016-11-10 16:44:08,743 newsLine:
<pre><p>    FRANKFURT, Nov 10 (Reuters) - Hannover Re  <Origin Href="QuoteRef">HNRGn.DE</Origin>  expects
reinsurance markets to remain largely unaffected by Donald Trump
becoming the next U.S. president, Chief Financial Officer Roland
Vogel said.
    "It will be important for us that the free trade of
reinsurance products remains unchanged. I do not see that being
affected," he said.     
    The United States is the largest single market for Hannover
Re, accounting for 30 percent of its premiums.

(Reporting by Arno Schuetze; Editing by Maria Sheahan)
((arno.schuetze@thomsonreuters.com; +49.69.7565.1197; Reuters
Messaging: arno.schuetze.reuters.com@reuters.net))

Keywords: HANNOVER RE RESULTS/USA ELECTION 
    
</p></pre>

the raw data in is same as println UTF8. The contents and lines also same as println UTF8 above.

thanks
 
Tim Moores
Bartender
Posts: 3132
50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you think the encoding is the problem if the error message apparently tells you that "newsBean" is null?

As an aside, those back and for conversions between encodings look fishy. For example, line 12 assumes that the document is encoded in the platform default encoding (since you specify no encoding), which may well not be the case.
 
Sharon Wong
Ranch Hand
Posts: 35
IBM DB2 Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
because i always get error when  reached "newsBean.setsContent_elasticNews(UTF8);"

"java.lang.NullPointerException
at com.n2n.reuters.newstrkd.client.imp.Tcp2ReutersNews.genNewsContentFromReuters2File(Tcp2ReutersNews.java:803)
at com.n2n.reuters.newstrkd.client.imp.Tcp2ReutersNews.run(Tcp2ReutersNews.java:296)
at java.lang.Thread.run(Thread.java:662)"
 
Sharon Wong
Ranch Hand
Posts: 35
IBM DB2 Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is create a new string based on document.


Please advice have any ideal for this coding?

Sorry, my programming experience for this part is fail..please kindly help on this.

Thank you


 
Sharon Wong
Ranch Hand
Posts: 35
IBM DB2 Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need set to setters file, because the contents need send to others java package.
If not, also please kindly advice how to save at elastic search there. have a good way for me?
the content also need sent to elasticsearch.

thanks
 
Tim Moores
Bartender
Posts: 3132
50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is "newsBean" null? If you haven't checked, start with that. Then look at line 803 of class Tcp2ReutersNews and check whether there are any null references being used.

String s2 = new String(document);

You should use the constructor that specifies an encoding - whatever the document is encoded in. The code you wrote seems to assume it's in ISO-8859-1.

I know nothing about ElasticSearch, so can't help with that.
 
Sharon Wong
Ranch Hand
Posts: 35
IBM DB2 Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
line 803 of class Tcp2ReutersNews is line  newsBean.setsContent_elasticNews(UTF8);

it should be not null, because UTF8 is not empty. UTF8 is come from 'String UTF8 = new String(s2.getBytes("ISO-8859-1"), "UTF-8");'. When i debug, UTF8 have contents.

at my newsBean.setsContent_elasticNews() at newbean.java set is

 
Tim Moores
Bartender
Posts: 3132
50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You misunderstand - I'm asking about "newsBean", not "UTF8". The latter couldn't possibly be null in line 16, because you're invoking a method on it in line 15. If it were null, you'd get an exception there.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic