源文件以下列方式存在: -
ABC
DFC
ADBC
我使用下面的代码打印文件中的每一行。
for /f "tokens=* delims=" %%a in ('type input.txt') do (
set line=%%a
echo %line%
)
但输出是
adbc
ADBC
ADBC
怎么办?所需的输出是:
ABC
DFC
ADBC
答案 0 :(得分:1)
除非您特别需要操纵该行或保存变量中最后一行的内容,否则绝对不需要使用 public class Fragment1 extends Fragment {
public Fragment1(){}
String stringValue;
int imagesResId;
TextView textView;
private int [] images = {R.drawable.nature2,R.drawable.nature4};
// static method to create the Fragment1 frag containing string
public static Fragment1 newInstance(String str, int imagesResId)
{
Fragment1 slider=new Fragment1();
Bundle b=new Bundle();
b.putString("stringValue", str);
b.putInt("images",imagesResId);
slider.setArguments(b);
return slider;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Log.i("x","onCreateViewFragment");
View view = inflater.inflate(R.layout.fragment1, container, false);
textView = (TextView) view.findViewById(R.id.textView);
return view;
}
// you will get data in this method where you can set value to your views
@Override
public void onActivityCreated(Bundle savedInstanceState) {
Log.i("x","onActivityCreatedFragment");
super.onActivityCreated(savedInstanceState);
stringValue = getArguments().getString("stringValue");
textView.setText(stringValue);
}
@Override
public void onCreate(Bundle savedInstanceState) {
Log.i("x","onCreateFragment");
super.onCreate(savedInstanceState);
imagesResId = getArguments().getInt("images");
stringValue = getArguments().getString("stringValue");
}
}
循环:
For
答案 1 :(得分:0)
setLocal EnableDelayedExpansion
for /f "tokens=* delims=" %%a in ('type input.txt') do (
set line=%%a
echo !line!
)