Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void transakcjaPobranieWiadomosciIMAP(int numerWiadomosci) throws IOException, ProtocolException, UnknownHostException
- {
- int znaki;
- char[] hasloCH = PFHaslo.getPassword();
- String hasloS = String.valueOf(hasloCH);
- String serwerIMAP = "imap." + TFSerwer.getText();
- int portIMAP = Integer.parseInt(TFIMAP.getText());
- Socket gniazdoIMAP = new Socket(serwerIMAP, portIMAP);
- int bajt, licznik, liczbaBajtow;
- FileOutputStream G_FOS = new FileOutputStream("wiadomosc_IMAP.txt", false);
- FileReader G_FR = new FileReader("wiadomosc_IMAP.txt");
- BRIMAP = new BufferedReader(G_FR);
- BufferedInputStream BIS = new BufferedInputStream(gniazdoIMAP.getInputStream());
- BufferedOutputStream BOS = new BufferedOutputStream(gniazdoIMAP.getOutputStream());
- PSIMAP = new PrintStream(BOS, true);
- InputStreamReader ISR = new InputStreamReader(gniazdoIMAP.getInputStream());
- BufferedReader BR = new BufferedReader(ISR);
- odpowiedzSerweraIMAP();
- wysylanieKomendIMAP("A001 LOGIN " + TFUzytkownik.getText() + " " + hasloS);
- odpowiedzSerweraIMAP();
- wysylanieKomendIMAP("A002 SELECT INBOX");
- odpowiedzSerweraIMAP();
- wysylanieKomendIMAP("A003 FETCH " + numerWiadomosci + " RFC822.TEXT");
- licznik = 0;
- do
- {
- znaki = BIS.read();
- licznik++;
- }
- while (znaki != 59);
- BIS.mark(licznik);
- BR.mark(licznik);
- BIS.reset();
- BR.reset();
- liczbaBajtow = BIS.available();
- for (int i = 0; i < liczbaBajtow; i++)
- {
- bajt = BIS.read();
- G_FOS.write(bajt);
- }
- wysylanieKomendIMAP("A004 LOGOUT");
- odpowiedzSerweraIMAP();
- G_FOS.close();
- BIS.close();
- BR.close();
- gniazdoIMAP.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement