我有一个脚本让RegExp获取存储在变量中的值数组。我需要将值存储在文件中。如何使用 bean shell post processor 来完成。我尝试过一个代码,它只在文件中存储一个值。请帮助我。
我的请求回复是
holder.recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
}
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if(dy > 0){
Log.e(TAG,"SCROLL =>"+"RIGHT");
}else{
Log.e(TAG,"SCROLL =>"+"LEFT");
}
// int currentVisible=lManger.findFirstVisibleItemPosition();
//
// Log.e(TAG,"FIRST VISIBLE=>"+firstVisible);
// Log.e(TAG,"CURRENT VISIBLE=>"+currentVisible);
// if(currentVisible > firstVisible){
// Log.e("RecyclerView scrolled: ", "scroll up!");
// if(temp!=blogBean1.getCount()) {
// if(temp > 1){
// holder.ivPrevious.setVisibility(View.VISIBLE);
// }
// temp++;
// Log.e(TAG,"UP TEMP VALUE IS=>"+temp);
// if(currentVisible+1==blogBean1.getCount()){
// holder.ivNext.setVisibility(View.GONE);
// }
// }
// }else{
// Log.e("RecyclerView scrolled: ", "scroll down!");
//
// if(temp!=0) {
// temp--;
// Log.e(TAG,"TEMP VALUES IS=>"+temp);
// holder.ivPrevious.setVisibility(View.VISIBLE);
// holder.ivNext.setVisibility(View.VISIBLE);
// }
// else if(firstVisible==0 && currentVisible==0){
// Log.e(TAG,"BOTH ZERO=>"+firstVisible+"\t Another=>"+currentVisible);
// holder.ivPrevious.setVisibility(View.GONE);
// holder.ivNext.setVisibility(View.VISIBLE);
// }
// }
// firstVisible = currentVisible;
}
});
我想使用bean shell将城市名称存储在一个文件中。如何做到。
答案 0 :(得分:0)
您似乎正在尝试使用Global Weather网络服务的响应
如果您需要将<City>
个节点的所有值保存到文件中,我建议您切换到JSR223 PostProcessor和Groovy language:
示例JSR223 PostProcessor Groovy代码将响应中找到的每个<City>
写入文件(新行中的每个城市),如下所示:
def slurper = new XmlSlurper()
def xml = slurper.parseText(prev.getResponseDataAsString())
def newDataSet = xml.'**'.find { node ->
node.name() == 'GetCitiesByCountryResult'
}
def filteredResult = slurper.parseText(newDataSet.toString())
def cities = filteredResult.'**'.findAll { node ->
node.name() == 'City'
}
cities.each {
new File('someFile.txt') << it << System.getProperty("line.separator")
}