Results 1 to 5 of 5

Thread: TCP send byte

  1. #1
    Koren3 is offline Member
    Join Date
    Apr 2009
    Posts
    50
    Rep Power
    0

    Default TCP send byte

    Hallo,
    How can i do it that, Program will send byte? Main how do cycle while.
    For example String:
    Java Code:
    String line;
                while ((line = keyboard.readLine())!= null)
                {   
     
                    zapis.write(line);
                    zapis.newLine();                
                    zapis.flush();
     
                    System.out.println("Reading:"+line);
                }

  2. #2
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    10

    Default

    You may need to rephrase that so we can understand the question.
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

  3. #3
    Koren3 is offline Member
    Join Date
    Apr 2009
    Posts
    50
    Rep Power
    0

    Default

    OK sorry. I need to rebuild this cycle so Cycle work with byte.
    For example.

    Java Code:
    BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));
    
    Security.addProvider(new BouncyCastleProvider());
                SecretKeySpec key = new SecretKeySpec("1234567891234567".getBytes("UTF-8"), "AES");
                    
                String nameAlgorithm = "AES/ECB/PKCS7Padding";
                Cipher cipher = Cipher.getInstance(nameAlgorithm);
                cipher.init(Cipher.ENCRYPT_MODE, key);
                
                byte[] encrypt = cipher.doFinal(keyboard.getBytes());
    
    byte line;
                while ((line = keyboard.readLine())!= null)
                {   
     
                    zapis.write(line);
                    zapis.newLine();                
                    zapis.flush();
     
                    System.out.println("Reading:"+line);
                }

  4. #4
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    10

    Default

    Nope, try again.
    What's a cycle? What's a zapis? What are you trying to do? What does your code actually do? Where is the problem? What is your specific question?
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

  5. #5
    Koren3 is offline Member
    Join Date
    Apr 2009
    Posts
    50
    Rep Power
    0

    Default

    Cycle = while. I need to do block cipher through TCP socket.
    Java Code:
    OutputStream out = socket.getOutputStream();
                BufferedWriter zapis = new BufferedWriter(new OutputStreamWriter(out));

Similar Threads

  1. Byte Array
    By sandor in forum New To Java
    Replies: 12
    Last Post: 01-15-2009, 04:31 AM
  2. using Byte arrays
    By mew in forum New To Java
    Replies: 2
    Last Post: 01-30-2008, 04:54 AM
  3. BufferedImage to Byte
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-22-2008, 09:17 PM
  4. int to byte
    By ravian in forum New To Java
    Replies: 1
    Last Post: 01-13-2008, 08:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •