Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. import java.io.*;
  2.  
  3. public class IntChar {
  4. private File input, output;
  5. private BufferedReader in;
  6. private BufferedWriter out;
  7.  
  8. public static void main(String[] args) {
  9. if(args.length != 2){
  10. System.out.println("Muss 2 Argumente haben");
  11. return;
  12. }
  13.  
  14. try {
  15. IntChar c = new IntChar(args[0], args[1]);
  16. c.start();
  17. } catch (IOException e){
  18. System.out.println(e);
  19. }
  20. }
  21.  
  22. public IntChar(String inputName, String outputName) throws IOException {
  23. input = new File(inputName);
  24. if(input.exists() == false || input.canRead() == false || input.isFile() == false)
  25. throw new IOException("Input nicht lesbar");
  26.  
  27. output = new File(outputName);
  28. if(output.exists() == true)
  29. throw new IOException("Output schon vorhanden");
  30.  
  31. in = new BufferedReader(new FileReader(input));
  32. out = new BufferedWriter(new FileWriter(output));
  33. }
  34.  
  35. public void start() throws IOException {
  36. try {
  37. int zeichen;
  38. char character;
  39.  
  40. while((zeichen = in.read()) != -1){
  41. character = (char) zeichen; // 32 -> ' '
  42. out.write(zeichen + ": " + character + "\n"); // Wandelt wieder um in Char
  43. }
  44.  
  45. } finally {
  46. in.close();
  47. out.close();
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement