import java.io.*;
import java.util.*;class p2
{
public static void main(String[] args)
{
try
{
BufferedReader br=new BufferedReader(new InputStreamReader(new FileInputStream("p1.java")));
DataOutputStream dos=new DataOutputStream(new FileOutputStream("pp.java"));
String str;Object o;
//while(br.ready())
while((str=br.readLine())!=null)
{
l.add(str);
//System.out.println(str);
}
//ListIterator it=l.listIterator();
int i=1;
while ((o=l.removeLast())!=null)
{
System.out.println((String)o);
dos.writeBytes(i+" "+(String)o+"\n");
i++;
}
while(it.hasNext())
{
System.out.println((String)it.next());
}
while(it.hasPrevious())
{
System.out.println((String)it.previous());
}
*/
//System.out.println("Hello World!");
}
catch (Exception e)
{
} }
}
import java.util.*;class p2
{
public static void main(String[] args)
{
try
{
BufferedReader br=new BufferedReader(new InputStreamReader(new FileInputStream("p1.java")));
DataOutputStream dos=new DataOutputStream(new FileOutputStream("pp.java"));
String str;Object o;
//while(br.ready())
while((str=br.readLine())!=null)
{
l.add(str);
//System.out.println(str);
}
//ListIterator it=l.listIterator();
int i=1;
while ((o=l.removeLast())!=null)
{
System.out.println((String)o);
dos.writeBytes(i+" "+(String)o+"\n");
i++;
}
while(it.hasNext())
{
System.out.println((String)it.next());
}
while(it.hasPrevious())
{
System.out.println((String)it.previous());
}
*/
//System.out.println("Hello World!");
}
catch (Exception e)
{
} }
}
解决方案 »
- HttpClient获取文件流的一部分
- 如何设置JAVA中对话框的文字字体,颜色?
- 菜虫求一个RLE简单算法代码
- 请问JRadioButton要使它由选中到不被选种的语句是什么??
- 将数字生成图片(就是类似生成验证码)
- 使用JTextArea和JScrollPane怎么实现滚动条自动下滚????
- 请强人帮忙,我想在JDesktopPane上显示一背景图.怎么办.
- 怎样现实一个有关数据库操作的类
- 这是小弟编的一个Clock Applet程序,可总是出错,高手指点,在线等!
- java 连接sqlserver2000 问题.
- 请教:一个AWT问题:为什么椭圆画不出来?
- java中的多态性用什么方法来解决
public FileOutputStream(File file,
boolean append)
throws FileNotFoundExceptionCreates a file output stream to write to the file represented by the specified File object. If the second argument is true, then bytes will be written to the end of the file rather than the beginning. A new FileDescriptor object is created to represent this file connection.
First, if there is a security manager, its checkWrite method is called with the path represented by the file argument as its argument. If the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason then a FileNotFoundException is thrown.
Parameters:
file - the file to be opened for writing.
append - if true, then bytes will be written to the end of the file rather than the beginning
Throws:
FileNotFoundException - if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason
SecurityException - if a security manager exists and its checkWrite method denies write access to the file.
Since:
1.4
See Also:
File.getPath(), SecurityException, SecurityManager.checkWrite(java.lang.String)
使用这个构造函数创建对象
用 append = false;