Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1.  
  2. public void stworzPlik() {
  3. File plik = new File(nazwaPliku);
  4.  
  5. boolean czyIstenieje = plik.exists();
  6. if (!czyIstenieje) {
  7. try {
  8. czyIstenieje = plik.createNewFile();
  9. } catch (IOException e) {
  10. System.out.println("nie udalo sie utworzyc pliku");
  11. }
  12. }
  13. if (czyIstenieje) {
  14. System.out.println("Pkik" + nazwaPliku + "istenieje lub zostal utworzony");
  15. }
  16.  
  17. }
  18.  
  19. public void zapisDoPliku(){
  20.  
  21. try{
  22. PrintWriter writer=new PrintWriter(nazwaPliku);
  23. writer.printf("%s%n", "Macierz");
  24. writer.printf("%d%n", liczbaWierszy);
  25. writer.printf("%d%n", liczbaKolumn);
  26.  
  27. for(int i=0; i<tab.length; i++){
  28. for(int j=0; j<tab[i].length; j++)
  29. writer.printf("%8.3d", tab[i][j]);
  30. }
  31. writer.printf("%n");
  32. }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement