Skip to content
Snippets Groups Projects
Commit 2207ca8f authored by Mika Pohto's avatar Mika Pohto
Browse files

1. tehtävä tehty

parents
No related branches found
No related tags found
No related merge requests found
import java.io.File;
import java.io.FileWriter;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Scanner;
public class tiedostonKaanto
{
public static String kaannaString(String s)
{
String r = "";
for(int i = 0; i < s.length(); i++)
{
r = r + s.charAt(s.length() - i - 1);
}
return r;
}
public static void main(String[] args) throws FileNotFoundException, IOException
{
String tiedostoNimi = args[0];
String tiedosto2Nimi = args[1];
File tiedosto = new File(tiedostoNimi);
File tiedosto2 = new File(tiedosto2Nimi);
Scanner s = new Scanner(tiedosto);
FileWriter op = new FileWriter(tiedosto2);
while(s.hasNextLine())
{
String rivi = s.nextLine();
op.write(kaannaString(rivi));
op.write(System.getProperty( "line.separator" ));
}
s.close();
op.close();
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment