java读取txt 保留原来格式(空行,空格。。。)
publicstaticStringgetRuleByTxt(){StringtheRule="";try{BufferedReaderin=newBufferedRea...
public static String getRuleByTxt()
{
String theRule = "";
try
{
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(new File("gobangrule.txt ")), "gb2312"));
String line = null;
while((line = in.readLine())!=null)
{
theRule = theRule + line;
}
}
catch (Exception e)
{
e.printStackTrace();
}
return theRule;
}
这段代码读取的txt返回然后打印就没有空行,貌似也没段落前后的空格了。
求解!!! 展开
{
String theRule = "";
try
{
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(new File("gobangrule.txt ")), "gb2312"));
String line = null;
while((line = in.readLine())!=null)
{
theRule = theRule + line;
}
}
catch (Exception e)
{
e.printStackTrace();
}
return theRule;
}
这段代码读取的txt返回然后打印就没有空行,貌似也没段落前后的空格了。
求解!!! 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询