Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package task_1;
- import java.io.*;
- public class Strings_inerview
- {
- public static void main(String[] args) throws IOException
- {
- int n=2;
- char in = 'x';
- String longestPol=" ";
- File file = new File("/Users/kolinsol/Documents/dev/example_text.txt");
- FileInputStream reader = new FileInputStream(file);
- byte MyString[] = new byte[(int)file.length()];
- reader.read(MyString);
- String OutString = new String(MyString);
- String[] OutStringArray = OutString.split(" ");
- for (int i=0; i<OutStringArray.length; i++)
- {
- System.out.println(OutStringArray[i].length());
- if(OutStringArray[i].length()>n)
- {
- StringBuilder tempString = new StringBuilder(OutStringArray[i]);
- tempString.setCharAt(n, in);
- System.out.println(tempString.toString());
- }
- else
- System.out.println(OutStringArray[i]);
- }
- System.out.println(longestPol);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement