pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

Advertising: personal loans - Mortgages - secured loan - Loans
Java paste-bin - collaborative debugging tool View Help

Posted by henrique on Mon 22nd Oct 20:09 (modification of post by view diff)
download | new post

  1.         public static void main(String[] args) throws FileNotFoundException {
  2.  
  3.                 //System.out.println("numero cromatico: " + coloracaoSequencialSimples(g));
  4.                
  5.                 byte[] dataEmail = new byte[10];
  6.                 String email = "[email protected]";
  7.                
  8.                 try {
  9.                         byte[] emailBytes = email.getBytes("ascii");
  10.                         System.arraycopy(emailBytes, 0, dataEmail, 0, emailBytes.length);
  11.                        
  12.                         // dataEmail é o que tu vai mandar pela rede
  13.                         System.out.println(Arrays.toString(dataEmail));
  14.  
  15.                         // aqui vamos supor que tu recebeu o byte e está na variável dataEmail
  16.                         int end = dataEmail.length-1;
  17.                         for ( ; end >= 0 && dataEmail[end] == (byte)0; end--);
  18.                        
  19.                         byte[] byteEmail = new byte[end + 1];
  20.                         System.arraycopy(dataEmail, 0, byteEmail, 0, byteEmail.length);
  21.                        
  22.                         String email_do_cara = new String(byteEmail, "ascii");
  23.                         System.out.println("convertido de volta: <" + email_do_cara + ">");
  24.                        
  25.                 } catch (UnsupportedEncodingException e) {
  26.                         // TODO Auto-generated catch block
  27.                         e.printStackTrace();
  28.                 }
  29.         }

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me
: