file read write

/* Hi there is some problem in read and write file

i am not getting how to resolve it

7 errors after compilation

D:\surekha\java\day3>javac ReadWrite1.java

ReadWrite1.java:18: ')' expected

outs.write(ch);

^

ReadWrite1.java:17: not a statement

(

^

ReadWrite1.java:11: 'try' without 'catch' or 'finally'

try

^

ReadWrite1.java:21: illegal start of type

catch(IOException e)

^

ReadWrite1.java:35: <identifier> expected

}

^

ReadWrite1.java:37: 'class' or 'interface' expected

}

^

ReadWrite1.java:39: 'class' or 'interface' expected

^

7 errors

*/

import java.io.*;

class ReadWrite1

{

public static void main(String s[])

{

File in=new File("in2.txt");

File out=new File("out2.txt");

FileReader ins=null;

FileWriter outs = null;

try

{

ins=new FileReader(in);

outs=new FileWriter(out);

int ch;

while((ch=ins.read())!=-1)

(

outs.write(ch);

}

}

catch(IOException e)

{

System.out.println(" ");

}

finally

{

try

{

ins.close();

outs.close();

}

catch(IOException e)

{

}

}

}

}

[1356 byte] By [SurekhaTa] at [2007-11-27 11:53:14]
# 1

You have mixed up the use of { and ( and it is giving the compiler headaches.

Right before the line outs.write(ch) you have this mistake. It may be repeated elsewhere.

When in future you post code please make an effort to use the code formatting tags it makes your code easier to read and understand and as such makes it easier for us to help you.

cotton.ma at 2007-7-29 18:49:08 > top of Java-index,Java Essentials,New To Java...
# 2

thaks a lot

SurekhaTa at 2007-7-29 18:49:08 > top of Java-index,Java Essentials,New To Java...