stardust Δημοσιεύτηκε December 11, 2003 Δημοσιεύτηκε December 11, 2003 ok, kommati asxeto ayto pu rwtaw alla pls opoios exei idea apo java boh8hste giati xanomaste.. Examine the following code that allows you to write and read Strings to and from file. Use this code to write sentences given by the user to a file. Each new input should be on a new line. The character for a new line is '\n'. The user should be able to keep typing in new sentences until they type "end". When the user has finished, read the content of the file and print it in reverse order. import java.io.*; //input and output classes public class Writing { public static void main(String[] args){ /** * Do not worry about understanding try or catch. These will be covered in a later lecture.. */ try { FileWriter writer = new FileWriter("m.txt",true); writer.write("Marina\n"); writer.close(); BufferedReader reader = new BufferedReader(new FileReader("c://m.txt")); String line = reader.readLine(); System.out.println(line); reader.close(); } catch(IOException e) { System.out.println("nn"); } } } ayth einai h m........, ama exei kaneis thn paramikrh idea ti prepei na kanw 8a tu sthsw agalma..... thanx.. Παράθεση http://victorian.fortunecity.com/hampton/426/unicorn-gallery/unicorn01/th/unicorn011th.jpg
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.