Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2016
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. public static void transakcjaPobranieWiadomosciIMAP(int numerWiadomosci) throws IOException, ProtocolException, UnknownHostException
  2. {
  3. int znaki;
  4. char[] hasloCH = PFHaslo.getPassword();
  5. String hasloS = String.valueOf(hasloCH);
  6.  
  7. String serwerIMAP = "imap." + TFSerwer.getText();
  8. int portIMAP = Integer.parseInt(TFIMAP.getText());
  9. Socket gniazdoIMAP = new Socket(serwerIMAP, portIMAP);
  10. int bajt, licznik, liczbaBajtow;
  11.  
  12. FileOutputStream G_FOS = new FileOutputStream("wiadomosc_IMAP.txt", false);
  13. FileReader G_FR = new FileReader("wiadomosc_IMAP.txt");
  14. BRIMAP = new BufferedReader(G_FR);
  15.  
  16. BufferedInputStream BIS = new BufferedInputStream(gniazdoIMAP.getInputStream());
  17. BufferedOutputStream BOS = new BufferedOutputStream(gniazdoIMAP.getOutputStream());
  18. PSIMAP = new PrintStream(BOS, true);
  19. InputStreamReader ISR = new InputStreamReader(gniazdoIMAP.getInputStream());
  20. BufferedReader BR = new BufferedReader(ISR);
  21.  
  22. odpowiedzSerweraIMAP();
  23.  
  24. wysylanieKomendIMAP("A001 LOGIN " + TFUzytkownik.getText() + " " + hasloS);
  25. odpowiedzSerweraIMAP();
  26.  
  27. wysylanieKomendIMAP("A002 SELECT INBOX");
  28. odpowiedzSerweraIMAP();
  29.  
  30. wysylanieKomendIMAP("A003 FETCH " + numerWiadomosci + " RFC822.TEXT");
  31. licznik = 0;
  32. do
  33. {
  34. znaki = BIS.read();
  35. licznik++;
  36. }
  37. while (znaki != 59);
  38.  
  39. BIS.mark(licznik);
  40. BR.mark(licznik);
  41. BIS.reset();
  42. BR.reset();
  43.  
  44. liczbaBajtow = BIS.available();
  45.  
  46. for (int i = 0; i < liczbaBajtow; i++)
  47. {
  48. bajt = BIS.read();
  49. G_FOS.write(bajt);
  50. }
  51.  
  52. wysylanieKomendIMAP("A004 LOGOUT");
  53. odpowiedzSerweraIMAP();
  54.  
  55. G_FOS.close();
  56.  
  57. BIS.close();
  58. BR.close();
  59. gniazdoIMAP.close();
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement