Advertisement
Guest User

Untitled

a guest
Jan 20th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. package zadanieJava;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.File;
  5. import java.io.FileNotFoundException;
  6. import java.io.FileReader;
  7. import java.io.IOException;
  8. import java.util.Scanner;
  9.  
  10. public class Zadanienr1 {
  11.  
  12. public static void main(String[] args) throws IOException{
  13. File plik = new File("dane1.txt");
  14. Scanner odczyt = new Scanner(plik);
  15. while(odczyt.hasNext()) {
  16. System.out.println(odczyt.nextLine());
  17. }
  18. }
  19.  
  20. }
  21.  
  22.  
  23.  
  24. package zadanieJava;
  25.  
  26.  
  27. import java.io.File;
  28. import java.io.FileInputStream;
  29. import java.io.FileReader;
  30. import java.io.IOException;
  31. import java.util.Scanner;
  32.  
  33. public class Zadanienr3 {
  34. public static void main(String[] args) throws IOException{
  35. File plik = new File("dane2.txt");
  36. Scanner odczyt = new Scanner(plik);
  37. FileInputStream odczytPliku = new FileInputStream(plik);
  38. byte [] a = new byte[(int) plik.length()];
  39. odczytPliku.read(a);
  40. odczytPliku.close();
  41.  
  42. String tekst = new String(a, "UTF-8");
  43. System.out.println(tekst);
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement