Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- *
- * @author DAIVOL
- */
- import java.util.*;
- import java.io.*;
- public class JapFormat
- {
- public static void main(String[] args) throws IOException
- {
- File file = new File("C:\\Users\\Daivol\\Documents\\NetBeansProjects\\jap\\test.txt"); // replace your txt file here, ONLY .txt FILE WORKS IN THIS
- Scanner inputFile = new Scanner(file);
- int k,i,j=0,x,y,l,m;
- ArrayList<char[]> chars = new ArrayList<>();
- do {
- chars.add(inputFile.nextLine().toCharArray());
- }while (inputFile.hasNext());
- char[][] line = chars.toArray(new char[chars.size()][]); //takes input line by line
- for(int a=1;a<line[0].length;a++)
- line[0][a-1]=line[0][a]; // since for some reason the first line input starts from 1 instead of 0, idk why
- k=line.length;
- /*for(i=0;i<k;i++)
- { l=line[i].length;
- m=i+1;
- System.out.println("line "+m + " length is "+l); // to see the length in different para
- if(j<line[i].length)
- {j=line[i].length;} //to get biggest length,but seems redundant since it works only when all line have same length
- }
- */
- for(x=0;x<k;x++)
- { for(y=0;y<line[x].length;y++)
- System.out.print(line[x][y]);
- l=line[x].length;
- m=x+1;
- System.out.println(" line "+m + " length is "+l); // ALL LENGTH NEED TO BE SAME IN OUTPUT
- }
- for(x=line[0].length-1;x>=0;--x)
- { for(i=0;i<k;i++)
- { System.out.print(line[i][x]);
- }
- System.out.println(); // YOU MAY NEED TO SKIP FIRST AND SECOND LINE WHILE COPYING FROM OUTPUT
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement