Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ppj28;
- import java.io.*;
- import java.io.FileReader;
- public class CodeFormeter {
- public static void main(String[] args) {
- File file = new File("C:\\Users\\s15678\\Desktop\\Ppj12.java");
- FileReader fis = null;
- StringBuffer output = new StringBuffer();
- try {
- fis = new FileReader(file);
- int tmp ;
- while((tmp=fis.read())!=-1){
- output.append((char)tmp);
- }
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }catch(IOException e){
- e.printStackTrace();
- }finally{
- try{
- if(fis!=null){
- fis.close();
- }
- }catch(IOException ex){
- ex.printStackTrace();
- }
- }
- System.out.println(output);
- String outp = output.toString();
- try{
- FileWriter fW = new FileWriter("C:\\Users\\s15678\\Desktop\\Ppj12_copy.java");
- for (int i = 0; i < outp.length(); i++) {
- if (outp.charAt(i)=='{') {
- fW.write(outp.charAt(i)+"\n"+"\t");
- } else
- fW.write(outp.charAt(i));
- }
- fW.close();
- }catch(Exception e){
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement