Jump to content

HELP HELP HELP


stardust

Recommended Posts

Δημοσιεύτηκε

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Επισκέπτης
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...