Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.85 KB | None | 0 0
  1. import java.io.FileWriter;
  2. import java.io.FileInputStream;
  3. import java.io.IOException;
  4. import java.util.Scanner;
  5.  
  6. public class Main {
  7.  
  8.     static void characterInsertion(byte[] Str) {
  9.         char[] cons  = {'E','e', 'U','u','I','i','O','o','A','a'};
  10.         StringBuffer str = new StringBuffer(String.valueOf(Str));
  11.         for (int i = 0 ; i < str.length(); i++){
  12.             if ( str[i] == cons[i]) {
  13.                 str.insert(str[i], "*");
  14.             }
  15.         }
  16.     }
  17.  
  18.     private static int currentIndex = -1;
  19.  
  20.     private static Integer next(String numbers[]) {
  21.         ++currentIndex;
  22.         while (currentIndex < numbers.length
  23.                 && numbers[currentIndex].equals(""))
  24.             ++currentIndex;
  25.         return currentIndex < numbers.length ?
  26.                 Integer.parseInt(numbers[currentIndex]) :
  27.                 null;
  28.     }
  29.  
  30.  
  31.  
  32.     static void saveFile(byte Str ) throws IOException {
  33.         Scanner in = new Scanner(System.in);
  34.         String outputFileName;
  35.         System.out.println("Введите имя файла в который хотите вывести данные:");
  36.         outputFileName = in.nextLine();
  37.         FileWriter out = new FileWriter(outputFileName);
  38.         out.write("\n Новая строка : " + Str );
  39.         out.close();
  40.     }
  41.  
  42.  
  43.     public static void main(String[] args) throws IOException {
  44.  
  45.         String NameOfFile;
  46.         Scanner in = new Scanner(System.in);
  47.         FileInputStream inFile = new FileInputStream("C:\\Users\\Asus\\Desktop\\fxujk.txt");
  48.         byte[] str = new byte[inFile.available()];
  49.         inFile.read(str);
  50.         String text = new String(str);
  51.         String[] numbers = text.split("\\C");
  52.         int n = next(numbers);
  53.         byte Str;
  54.         inFile.close();
  55.         Str = characterInsertion(str);
  56.         saveFile(Str);
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement