开发者

Error in Writing a text file "Exception in thread "main" " [duplicate]

This question already has answers here: Closed 10 years ago.

Possible Duplicate:

Causes of 'java.lang.NoSuchMethodError: main Exception in thread “main”'

I am trying to write a byte array in a text file. It is giving me error:

java.lang.NoSuchMethodError: main Exception in thread "main"

The code i am using is as under

    import java.io.BufferedWriter;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.io.Writer;
    public class writefile {
//it works well
    public static void main()throws IOException{
        Writer output = null;
      byte[] a= {1,2,3,4,5,6};

       try {
      String text = "abcd...\n";
      String str3 = text.concat("the end");
      String NL = System.getProperty("line.separator");
      str3 = str3.concat(NL);
      str3= str3.concat("next line");
      for ( in开发者_如何学Got i=0; i < a.length; i++){
          str3 = str3.concat(NL);
          str3= str3.concat(" " +a[i]);
      }
      File file = new File("write.txt");
      output = new BufferedWriter(new FileWriter(file));
      output.write(str3);
      System.out.println("Your file has been written");
      } catch (FileNotFoundException e) {
          e.printStackTrace();
          } catch (IOException e) {
          e.printStackTrace();
          } finally {
              try {
                  if (output != null) {
                      output.close();
                      }
                  } catch (IOException e) {
                      e.printStackTrace();
                      }
                  }
      }

}

Kindly help how can i resolve the problem.


The main method of a Java program must take an argument of type String[] representing the arguments (if any) passed to the program on launch.


the main signature must contain String[] argument

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜