抱歉这个愚蠢的问题......有人可以帮我从方法中返回两个变量吗(我在这里阅读 并尝试重新编码但没有结果)。
public class FileQualityChecker {
EnviroVars vars = new EnviroVars();
public int n = 0;
public int z = 0;
public int m = 0;
String stringStatus;
public void stringLenghtCheck(String pathToCheckedFile)
{
try{
FileInputStream fstream = new FileInputStream(pathToCheckedFile+"\\"+"Test.dat");
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
//Read File Line By Line
while ((strLine = br.readLine()) != null)
{
if (
strLine.length() == vars.strLenghtH ||
strLine.length() == vars.strLenghtCUoriginal ||
strLine.length() == vars.strLenghtCEAoriginal ||
strLine.length() == vars.strLenghtCAoriginal ||
strLine.length() == vars.strLenghtTrailer ||
strLine.length() == vars.strLenghtLastRow
)
{
stringStatus = "ok";
n++;
z++;
}
else
{
stringStatus = "Fail";
n++;
m++;
}
System.out.println (n +" " + strLine.length() +" " + stringStatus);
}
//Close the input stream
in.close();
}
catch
(Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
/*How to return m and z from method to use these vars for writing in the file*/
return (m, z);
}
}
我需要另一个类中的 m 和 z 将它们写入文件。谢谢你。