Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert String to Text (Java Hadoop)

I have the following problem:

I want to split a Text value that I get from a file.

The value format is "12,23"

I want to take the first value in a variable a=12 and the second value in a variable b=23.

I use String.split(","); to do that. The problem is that I want to assign these values in Text variables.

I tried the following and it doesn' t work

Text text=(Text) a; 
like image 577
Mike B Avatar asked Mar 31 '13 19:03

Mike B


1 Answers

Use the constructor Text(String string):

String s = "12,23";
String[] array = s.split(",");
Text t1 = new Text(array[0]);
Text t2 = new Text(array[1]);
like image 89
Eng.Fouad Avatar answered Sep 30 '22 17:09

Eng.Fouad