我有一个数组中的字符串。我需要将基于索引的数组的所有元素附加到 mapreduce 中的 Text()
。我需要将值作为字符串附加到 Text()
例如:
String s = "12,23";
String[] array = s.split(",");
Text t1 = new Text();
for(int i=0;i<array.length;i++) {
t1.append(array[i]);
}
最佳答案
您可以这样做而不需要拆分字符串数组:
String str = "12,23";
String newStr = str.replace("," , ""); // or replace with any character or string you want between those numbers
Text text = new Text(newStr);
关于java - 如何将数组中的字符串附加到 mapreduce 中的 Text(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39507607/