cs-joke.pl forum
Konwertuj na język Java - Printable Version

+- cs-joke.pl forum (https://cs-joke.pl)
+-- Forum: Komputery (https://cs-joke.pl/forum-1.html)
+--- Forum: Windows (https://cs-joke.pl/forum-4.html)
+--- Thread: Konwertuj na język Java (/thread-22960.html)



Konwertuj na język Java - aroy.gil - 06 Feb 2018

Konwertuj na język Java


RE: Konwertuj na język Java - chillimaster007 - 06 Feb 2018

import java.io. *; public class ReadFile { public static void main (String [] args) { if (args.length == 0) { System.out.println ("Proszę podać plik źródłowy jako pierwszy parametr!"); System.exit (1); } String targetFilename = "target.txt"; String sourceFilename = args [0] .trim (); Plik targetFile = nowy Plik (nazwa_celu); Plik sourceFile = new Plik (sourceFilename); if (targetFile.exists ()) { System.out.println ("Plik docelowy już istnieje. Usuń go najpierw"); } jeszcze { BufferedReader in = null; BufferedWriter out = null; próbować { in = new BufferedReader (nowy FileReader (sourceFile)); out = new BufferedWriter (nowy FileWriter (targetFile)); Linia ciągu; while ((line = in.readLine ())! = null) { out.write (linia); out.newLine (); } } catch (IOException e) { System.out.println (e.getMessage ()); } Wreszcie{ spróbuj {if (in! = null) in.close (); } catch (Exception e) {