先建立c:\\2.txt
然后在2.txt这样写入* * * * * 然后这样读出 *
* c * * a *
* * * * * *
有朋友会做吗?谢谢!
然后在2.txt这样写入* * * * * 然后这样读出 *
* c * * a *
* * * * * *
有朋友会做吗?谢谢!
解决方案 »
- 关于编程工具
- telnet localhost 1433 时,连接失败该怎样解决???
- 求 《JAVA与UML协同应用开发》书内所有源代码!
- Jpanel显示图片问题!
- 弄过cvs版本控制的进来帮忙解答下!
- 请教关于jsp调用oracle存储过程出现的问题!万分感谢!
- 这样配servlet真奇怪 这样也有问题??不解 望高手支招
- 有谁知道 java5.0( jdk1.5) 的新特性吗?最好详细一点 的。介绍几个网页也可以。
- 怎么用JAVAPrint出一个杨辉三角
- 求教 win98+mysql+tomcat+apache+jsp+php的配置
- 应界毕业生,对于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 *
* * * * *
就是这样.