Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.net.*;
- import java.io.*;
- public class Server_D{
- public static void main(String[] args){
- try{
- ServerSocket server = new ServerSocket(8888);
- Socket client = null;
- BufferedReader in;
- System.out.println("Server pronto \n");
- Integer conta = 0;
- while(true){
- client = server.accept();
- in = new BufferedReader(new InputStreamReader(client.getInputStream()));
- String mex = in.readLine();
- System.out.println(mex+"\n");
- PrintWriter out = new PrintWriter(client.getOutputStream(), true);
- conta = conta_maiuscole(mex); // variabile intera
- out.println(conta.toString()); //tostring
- client.close();
- }
- }
- catch (Exception e){
- e.printStackTrace();
- }
- }
- public static int conta_maiuscole(String str){
- int count = 0;
- for(int i=0; i<str.length(); i++){
- if ( Character.isUpperCase(str.charAt(i)) ) count++;
- }
- return count;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement