先建立c:\\2.txt
然后在2.txt这样写入* * * * * 然后这样读出 *
* c * * a *
* * * * * *
有朋友会做吗?谢谢!
然后在2.txt这样写入* * * * * 然后这样读出 *
* c * * a *
* * * * * *
有朋友会做吗?谢谢!
解决方案 »
- java一些细节问题,对java理解深刻的进~
- 怎么使socket连接别的机子
- 问下,java中this的这种写法怎么理解呢
- 虚心请教,请大家指点!关于字符窜空值null的问题,很迷惑
- JAVA 里面有没有集合运算的方法啊
- 如何制作进度条?
- float类型转化成int 类型
- java子类中能调用其它子类方法吗
- (在线等)Exception in thread "main" java.lang.NoClassDefFoundError: Hello
- 一个图形文件,如一个JPG图形文件,怎么才能通过流读进来,然后转化成一个字节数组。
- 应界毕业生,对于java的困惑,定散分
- 如何用java实现类似于qq好友分组的功能。
///////////////////////////////////////////////
对阿,啥情况阿。
读出来放到变量里面,例如StringBuffer,然后倒置一下不就行了
如果c==>a是要求的,那么就碰到字母按你
的要求转一下
class ceshi
{ private File file=new File("C:\\2.txt");
public static void main(String args[])throws Exception{
ceshi ms=new ceshi();
ms.writeString();
ms.readString();
}
public void writeString()throws Exception{
PrintWriter pw=new PrintWriter(new FileOutputStream(file));
pw.println("* * * * *");
pw.println(" * c *");
pw.println(" *");
//System.out.println("* * * * *");
pw.close();
}
public void readString()throws Exception{
String pc[]=new String[3];
int n=3;
BufferedReader gs=new BufferedReader(new InputStreamReader (new FileInputStream(file)));
for(int i=0;i<3;i++){
//if(gs.readLine()!=null){
pc[i]=gs.readLine();//} /*else{
System.out.println("ji lu bu cun zai");
break;
}*/
}
for(int i=2;i>=0;i--){
if(pc[i].trim().equals("* c *")){
System.out.println(" * a * ");
}
else
System.out.println(pc[i]);
}
}
}
意思是这样的:
首先在C:盘下建立一个2.txt文件
然后往C:盘里的2.txt文件里写入* * * * *
* c *
*
然后在屏幕里显示: *
* a *
* * * * *
就是这样.