[英]How can i make that everything after “,” in .txt file will be checked separetly :)?
I need to improve this code that will read from a text file named file.txt
我需要改进将从名为
file.txt
的文本文件中读取的代码
sergy,many,mani,kserder
sergy,许多,mani,kserder
I would like to use this form:我想使用这种形式:
file = login.getText();
if (file.equals("sergy"))
I just need to do something that will read everything in the text file separately and ignoring "," sign, or something else other than "," sign.我只需要做一些事情,分别读取文本文件中的所有内容并忽略“,”符号或“,”符号以外的其他内容。
You could split the string by the ,
character and check if any of the array's elements are equal to the value you're looking for:您可以通过
,
字符拆分字符串并检查数组的任何元素是否等于您要查找的值:
file = login.getText();
if (Arrays.asList(file.split(",")).contains("sergy")) {
// do something...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.