Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners illegal start of type

Have Programming Question? Ask it here!
 
 
 


kavisuruli
illegal start of type
1 Answer(s)      a year and 2 months ago
Posted in : Java Beginners


Hi, This is my code i m getting illegal start of type as error when i m compiling it,can anyone pls help me to correct this error.

public class WriteByteArrayToFile 
{
public static void main(String[] args)
{

String strFilePath = "C://Program Files/Java/jdk1.7.0_23/bin//s.excel";

try

{
FileOutputStream fos = new FileOutputStream(strFilePath);

int numberBytes = fileinputstream.available();
            byte bytearray[] = new byte[numberBytes];

            fileinputstream.read(bytearray);

            for(int i= 0;i < numberBytes;i++)
{
                System.out.println(bytearray[i]);
            }

            fileinputstream.close();
            }
            catch(Exception e)
            {
            System.out.println(e);
MyReader mr = new MyReader();
mr.ReadFile("side1-60.java");           }
String strContent = "side1-60.java ";

 fos.write(strContent.getBytes());

 fos.close();

 }
catch(FileNotFoundException e)
{
System.out.println("FileNotFoundException : " + ex);
}catch(IOException ioe) {

System.out.println("IOException : " + ioe);
}
}

Advertisement
View Answers

May 18, 2013 at 4:05 PM


hi friend,

Check your code properly you have misplaced the closing curly braces

import java.io.*;

public class WriteByteArrayToFile 
{ 
    public static void main(String[] args) 
    {
        String strFilePath = "writingFilePath";
        FileOutputStream fos = null;
        try
        {
            fos = new FileOutputStream(strFilePath);
            FileInputStream fileinputstream = new FileInputStream("readingFilePath");
            int numberBytes = fileinputstream.available();
            byte bytearray[] = new byte[numberBytes];
            fileinputstream.read(bytearray);
            for(int i= 0;i < numberBytes;i++)
            {
                System.out.println(bytearray[i]);
            }
            fileinputstream.close();
        }
        catch(FileNotFoundException e)
        {
            System.out.println(e);
            /*MyReader mr = new MyReader();
            mr.ReadFile("side1-60.java");*/
        //}
        String strContent = "side1-60.java ";
        try {
            fos.write(strContent.getBytes());
            fos.close();
            }
        catch (IOException e1) 
        {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        }
   catch(IOException ex) 
   {
       System.out.println("FileNotFoundException : " + ex); 
   }
   catch(Exception ioe)
   {
       System.out.println("IOException : " + ioe); 
   }
}
}

Thanks.



Related Tutorials/Questions & Answers:
illegal start of type
illegal start of type  Hi, This is my code i m getting illegal start of type as error when i m compiling it,can anyone pls help me to correct this error. public class WriteByteArrayToFile { public static void main(String
illegal start type, HELP!
illegal start type, HELP!  import java.util.Scanner; public class... is " + shipping + " dollars."); } } } Illegal start type error? help?   ... keyboard = new Scanner(System.in); System.out.print("Please type the total number
Advertisements
illegal start of type
illegal start of type  Hello! I'm very new to writing java. And I keep getting the "Illegal Start of Type" error. I've tried everything to fix... for room type=new JLabel("Type: "); roomno=new JLabel("roomNo
Illegal Start of Type
Illegal Start of Type  Hello! I'm very new to writing java. And I keep getting the "Illegal Start of Type" error. I've tried everything to fix...,"North"); // building interface for room type=new JLabel("Type: "); roomno=new
Java error illegal start of type
Java error illegal start of type       The Java error illegal start of type...;} } On Compilation the code show an illegal start of type error. Output
illegal start of expression in servlet error..
illegal start of expression in servlet error..  hello Sir, here is my servlet code and i am getting illegal start of expression error in declaring the method named " public Boolean ModificarUsuario(int IdUsuario
illegal start of expression - Java Beginners
illegal start of expression  here i attach my program.. which shows illgal start of expression.. plz aynone will silve this particular problem.. and correct this particular program.. plz help me
i got illegal start of expression error , plese tell me the mistake where i did...
i got illegal start of expression error , plese tell me the mistake where i did...   import org.springframework.context.*; import java.util.*; public class MyListener implements ApplicationListener { public static void main
Subset Tag (Control Tags) Example Using Start
the start parameter. The start parameter is of integer type. It indicates... a subset of it. The parameter start is of integer type and it indicates...Subset Tag (Control Tags) Example Using Start   
Class Cast & illegal state Exception in blackberry
Class Cast & illegal state Exception in blackberry  tell me please i m facing class cast exception. when i click on Maps & iGoogle in Google Homepage on my emulator then it gives class cast & Illegal State exception
start and deploy
start and deploy  how to deployee java web application in glassfish by using netbeans6.7
obj_start()
obj_start()  hii, What is the use of obj_start()?   hello, Its initializing the object buffer, so that the whole page will be first parsed and stored in output buffer so that after complete page is executed
start pyramid
start pyramid  how to make program use loop to make the output become like this; * ** ** *   import java.lang.*; class Star { public static void main(String args[]) { int k,i,j,p=4; for(i=1;i<5;i
java util date - Time Zone throwing illegal argument exception
java util date - Time Zone throwing illegal argument exception  Sample Code String timestamp1 = "Wed Mar 02 00:00:54 PST 2011"; Date d = new Date... is throwing an Illegal Argument Exception Why is the second SOP always throwing
Start MySQL on Linux
Start MySQL on Linux  hii, How can i start MySQL on Linux? is there any cmd for starting MySQL on linux?   hi, yeah , By typing this cmd you can start MySQL service mysqld start
could not start server. - EJB
could not start server.  Dear All I have installed netbeans 5.5.1 and sun java Application server 9.2 to run ejb program. But when I start... comes ---sun java server could not start. so what should I do to start this server
where to start - Java Beginners
where to start  Myself being a java beginner want to know wat is that I shall start practicing from the day one to make myself get the knowledge... on.   Hi, Thanks for using RoseIndia.net You can start learning java
type casting
type casting  what is type casting
Type casting
Type casting  how to type cast a string value to byte array
JFrame Button click to start play
JFrame Button click to start play  i made a game and and i add a button in new jframe and i want when i click it it start to play...can anyone help me
type casting
List (object type) <Object> totalList(int pi){ try{ Query q...type casting  <--bean class-->method calllist is of object type...){ return null; } how to type cast object type to entity type
type mismatch
type mismatch  Statement s= con.createStatement(); this line gives error of "type mismatch" I am using eclips nd new to servlet nd JDBC, Please help me, Thank you
type casting
type casting  int n=20; n=sizeof((char)(float)n); what is n value
data type
data type  which data type is used to store video file in mysql databse
how to start with java - Java Beginners
how to start with java  sir i am new to java and i need the guidence how to start with it . i am doing my MCA final semester project . the project is based on jsp so suggest me the way to follow and cope up with this technology
Week calculate start from friday
Week calculate start from friday  My problem is to calculate how many weeks have a month. Note that my weeks have to start on Friday! I have three combo boxes. First display year. Second one display month. Third one display
Java Web Start and Java Plug-in
extension and mime type associations with Java Web Start application, you can... Java Web Start Enhancements in version 6  ... Java Web Start should check for updates on the web, and what to do when
Java Kick Start - Java Beginners
in core java, collections then you can start with JSP and Servlets. http
Java Web Start
Java Web Start       Sun Microsystems has developed a framework named Java Web Start. This framework allows us to directly start application software for the Java
Struts Quick Start
Struts Quick Start Struts Quick Start to Struts technology In this post I will show you how you can quick start the development of you struts based project... of the application fast. Read more: Struts Quick Start
String Start with Example
String Start with Example      ... that start from the specified character in java. The following program checks...() function it will return 'true' and display a message "The given string is start
start debugging problems related to the JDBC API
start debugging problems related to the JDBC API  How do I start debugging problems related to the JDBC API
Explain about threads:how to start program in threads?
Explain about threads:how to start program in threads?  import... to type something and show date and time simultaneously you can use threads.... Start, run, stop. Threads can be started using start method, the start
how to start a java project from scratch level
how to start a java project from scratch level   1.how to start a java project from scratch level ?can u give me small example from design to development process
start tomcat automatically by double clicking on exe
start tomcat automatically by double clicking on exe  Hi I wanted to start tomcat automatically by double clicking on exe. i made project in jsp... start and simultaneously my first.jsp should start. PLZ help me out
start date and end date validation in javascript - Ajax
start date and end date validation in javascript  hi, i am doing web surfing project. pls guide me for my project. i want start date and end validations in javascript. end date should be greater than start date if so less than
java.sql.SQLExceptioan: Before start of result set - JDBC
java.sql.SQLExceptioan: Before start of result set   java.sql.SQLException: Before start of result set?what do i do?   Hi Friend, It seems that there is a problem with the resultSet.next() method: It is used before
SQL get start date and end date result
SQL get start date and end date result  how to get ( 15 march 2011) and (15/03/2011) output using SQL
jquery start date end date validation
jquery start date end date validation  Using JQuery how can i validate the end date and start date? for example if the start date is grater than the end date?   jQuery.validator.addMethod("greaterThan", function(value
Start with working program
is similar to the desired program, many professional programmers will start... Start with an existing program which is running. Use a previous program of your own... is not to copy a program in its entirety, but to start with another program or part
coding for re-type password
coding for re-type password  coding for re-type password
Document Type Definition
Document Type Definition  What is Document Type Definition
fastest type of JDBC driver
fastest type of JDBC driver  What is the fastest type of JDBC driver
how to start quartz in server - IDE Questions
how to start quartz in server  Hi, Thank you very much, you made me to get through easy from quartz scheduling. Actually I am facing a general problem that when I execute quartz in local system I can run this schedule class
Reference type Vs Object type. - Java Beginners
Reference type Vs Object type.  Can anyone explain the exact... or object type variable which may reference a Book object or an object of any... of Employee Class 'Employee' would be the REFERENCE TYPE and Class
How a beginner can start Java Programming?
How a beginner can start Java Programming?  I Just have programming knowledge of C & C++. Let's know how I can learn Java? Is there any Java tutorial for beginners on roseindia.net website? Thanks   Hi, Since you
tomcat server start up error - Struts
tomcat server start up error   Hai friends..... while running... org.apache.catalina.core.StandardService start INFO: Starting service Catalina Sep 5, 2009 4:49:08 AM org.apache.catalina.core.StandardEngine start INFO: Starting Servlet Engine: Apache
Fastest type of JDBC Driver
Fastest type of JDBC Driver  hello, What is the fastest type of JDBC driver?   hii, Type 4 is the fastest JDBC driver
Java type casting
Java type casting  What is Downcasting
eraser type generics in java
eraser type generics in java  Explain eraser type generics in java with example
Advertisements
 

 

 

DMCA.com