-4

I tried to save the output into a file but it's not working please provide me with a solution this code prints all the combinations of the given string this code works properly but I'm unable to save this into a file I can't copy paste from terminal

import java.util.*; 

class psw 
{ 


    static void generate(char[] arr, int i, String s, int len) 
    { 

        if (i == 0) 
        { 

            System.out.println(s); 


            return; 
        } 
          for (int j = 0; j < len; j++) 
        { 


            String appended = s + arr[j]; 
            generate(arr, i - 1, appended, len); 
        } 

        return; 
    } 


    static void crack(char[] arr, int len) 
    { 

        for (int i = 1; i <= len; i++) 
        { 
            generate(arr, i, "", len); 
        } 
    } 


    public static void main(String[] args) 
    { 
        char arr[] = {'a', 'b', 'c'}; 
        int len = arr.length; 
        crack(arr, len); 
    } 

}
Akshit
  • 424
  • 4
  • 15
Naga Teja
  • 5
  • 1

1 Answers1

0

If you want to save the outputs on the console to a file you can simply redirect System.out like explained in this question.

So all the outputs on the console (that are printed using System.out) are not printed on the console, but in a file.

Tobias
  • 2,547
  • 3
  • 14
  • 29