Advertisement
Guest User

Java Class

a guest
Sep 17th, 2010
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 4.48 KB | None | 0 0
  1. package com.votaguz.Testing;
  2.  
  3. import java.io.IOException;
  4. import java.util.HashMap;
  5. import java.util.Scanner;
  6.  
  7.     public class Testing { 
  8.         public static HashMap<String, String> CHARS_7BIT;
  9.        
  10.         static{
  11.         CHARS_7BIT = new HashMap<String, String>();
  12.          CHARS_7BIT.put("@", "0000000");
  13.          CHARS_7BIT.put("$", "0000010");
  14.          CHARS_7BIT.put("\r", "0000000");
  15.          CHARS_7BIT.put("\n", "0001010");
  16.          CHARS_7BIT.put("∆", "0000000");
  17.          CHARS_7BIT.put("Φ", "0000000");
  18.          CHARS_7BIT.put("Γ", "0000000");
  19.          CHARS_7BIT.put("Λ", "0000000");
  20.          CHARS_7BIT.put("Ω", "0000000");
  21.          CHARS_7BIT.put("∏", "0000000");
  22.          CHARS_7BIT.put("@", "0000000");
  23.          CHARS_7BIT.put("@", "0000000");
  24.          CHARS_7BIT.put("@", "0000000");
  25.          CHARS_7BIT.put("@", "0000000");
  26.          CHARS_7BIT.put("@", "0000000");
  27.          CHARS_7BIT.put("@", "0000000");
  28.          CHARS_7BIT.put("!", "0100001");
  29.         // CHARS_7BIT.put(""", "0100010");, "\r",, , , , , , "Ψ", "∑", "Θ", "Ξ", ",", "ß",
  30.          CHARS_7BIT.put("#", "0100111");
  31.         CHARS_7BIT.put("%", "0100101");
  32.         CHARS_7BIT.put("&", "0100110");
  33.         CHARS_7BIT.put("`", "0100111");
  34.         CHARS_7BIT.put("(", "0101000");
  35.         CHARS_7BIT.put(")", "0101001");
  36.         CHARS_7BIT.put("*", "0101010");
  37.         CHARS_7BIT.put("+", "0101011");
  38.         CHARS_7BIT.put("'", "0101100");
  39.         CHARS_7BIT.put("-", "0101101");
  40.         CHARS_7BIT.put(".", "0101110");
  41.         CHARS_7BIT.put("/", "0101111");
  42.         CHARS_7BIT.put("0", "0110000");
  43.         CHARS_7BIT.put("1", "0110001");
  44.         CHARS_7BIT.put("2", "0110010");
  45.         CHARS_7BIT.put("3", "0110011");
  46.         CHARS_7BIT.put("4", "0110100");
  47.         CHARS_7BIT.put("5", "0110101");
  48.         CHARS_7BIT.put("6", "0110110");
  49.         CHARS_7BIT.put("7", "0110111");
  50.         CHARS_7BIT.put("8", "0111000");
  51.         CHARS_7BIT.put("9", "0111001");
  52.         CHARS_7BIT.put(":", "0111010");
  53.         CHARS_7BIT.put(";", "0111011");
  54.         CHARS_7BIT.put("<", "0111100");
  55.         CHARS_7BIT.put("=", "0111101");
  56.         CHARS_7BIT.put(">", "0111110");
  57.         CHARS_7BIT.put("?", "0111111");
  58.         CHARS_7BIT.put("A", "1000001");
  59.         CHARS_7BIT.put("B", "1000010");
  60.         CHARS_7BIT.put("C", "1000011");
  61.         CHARS_7BIT.put("D", "1000110");
  62.         CHARS_7BIT.put("E", "1000111");
  63.         CHARS_7BIT.put("F", "1001000");
  64.         CHARS_7BIT.put("G", "1001001");
  65.         CHARS_7BIT.put("H", "1001010");
  66.         CHARS_7BIT.put("I", "1001011");
  67.         CHARS_7BIT.put("J", "1001100");
  68.         CHARS_7BIT.put("K", "1001101");
  69.         CHARS_7BIT.put("L", "1001110");
  70.         CHARS_7BIT.put("O", "1001111");
  71.         CHARS_7BIT.put("P", "1010000");
  72.         CHARS_7BIT.put("Q", "1010001");
  73.         CHARS_7BIT.put("R", "1010010");
  74.         CHARS_7BIT.put("S", "1010011");
  75.         CHARS_7BIT.put("T", "1010100");
  76.         CHARS_7BIT.put("U", "1010101");
  77.         CHARS_7BIT.put("V", "1010110");
  78.         CHARS_7BIT.put("W", "1010111");
  79.         CHARS_7BIT.put("X", "1011000");
  80.         CHARS_7BIT.put("Y", "1011001");
  81.         CHARS_7BIT.put("Z", "1011010");
  82.         CHARS_7BIT.put("@", "1011011");
  83.         CHARS_7BIT.put("@", "1011100");
  84.         CHARS_7BIT.put("@", "1011110");
  85.         CHARS_7BIT.put("@", "0000000");
  86.         CHARS_7BIT.put("a", "1100001");
  87.         CHARS_7BIT.put("b", "100010");
  88.         CHARS_7BIT.put("c", "1100011");
  89.         CHARS_7BIT.put("d", "1100100");
  90.         CHARS_7BIT.put("e", "1100101");
  91.         CHARS_7BIT.put("f", "1100110");
  92.         CHARS_7BIT.put("g", "1100111");
  93.         CHARS_7BIT.put("h", "1101000");
  94.         CHARS_7BIT.put("i", "1101001");
  95.         CHARS_7BIT.put("j", "1101010");
  96.         CHARS_7BIT.put("k", "1101011");
  97.         CHARS_7BIT.put("l", "1101100");
  98.         CHARS_7BIT.put("m", "1101101");
  99.         CHARS_7BIT.put("n", "1101110");
  100.         CHARS_7BIT.put("o", "1101111");
  101.         CHARS_7BIT.put("p", "1110000");
  102.         CHARS_7BIT.put("q", "1110001");
  103.         CHARS_7BIT.put("r", "1110010");
  104.         CHARS_7BIT.put("s", "1110011");
  105.         CHARS_7BIT.put("t", "1110100");
  106.         CHARS_7BIT.put("u", "1110101");
  107.         CHARS_7BIT.put("v", "1110110");
  108.         CHARS_7BIT.put("w", "1110011");
  109.         CHARS_7BIT.put("x", "1111000");
  110.         CHARS_7BIT.put("y", "1111001");
  111.         CHARS_7BIT.put("z", "1111010");
  112.         CHARS_7BIT.put("ä", "1111011");
  113.         CHARS_7BIT.put("ö", "1111100");
  114.         CHARS_7BIT.put("ü", "1111110");//, , ""
  115.        
  116.         }
  117.        
  118.        
  119.         public static void main(String []args) throws IOException{
  120.  
  121.             Scanner in = new Scanner(System.in);
  122.        
  123.             while(in.hasNext()) {
  124.                 to7Bits(in);
  125.             }
  126.     }
  127.        
  128.         //TODO : Los caracteres especiales no funcionan con el juego de caracteres que tenemos en el hashMap. So, hay que buscar una manera
  129.         //de representar estos caracteres especiales.
  130.        
  131.         public static void to7Bits(Scanner input){
  132.            
  133.             int i=0;
  134.                 String str = input.nextLine();
  135.                
  136.                 while(i < str.length()){
  137.                     char c = str.charAt(i);
  138.                     System.out.print(" "+CHARS_7BIT.get(Character.toString(c)));
  139.                     i++;
  140.                 }
  141.         }
  142. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement