Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-11-2008, 01:57 PM
Member
 
Join Date: May 2008
Posts: 1
MrKP is on a distinguished road
Cannot get passed these syntax errors
Good morning to you and I'm new to Java, but taking classes and getting to understand it better. However, this post was due a week ago and still having problems with the below code and it reads:

Project: Modified client to send the contents of this file, from client to server through the localhost; or indicate that the files does not exist. Connection from client and server established and wanted to send an XML file and make corrections, then send it back to the server on my local machine. Could someone help me, please because this makes you not look to do any programming.

A similar example from "Java: A Beginners Guide"

#1:

/* Display a .xml file
* java ShowFile FIRST.Client-ServerFile
*/

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.FileInputStream;

public class ShowFile {
private static boolean IOException;

private static Object args;

@SuppressWarnings("empty-statement")
private static void main (String arg[])
{
int c;
FileInputStream fin;

// File has been specified.
if (args.length != 1) {
System.out.println( "Usage: ShowFile .XML");
return;
}
try {
fin = new FileInputStream(args[0]);
} catch (FileNotFoundException exc){
System.out.println("File Not Found");
return;
}
try {
// read bytes until EOR is encountered
do {
c = fin.read();
if ( c != -1) {
System.out.println((char) c);
} while (c != -1); //end of file reached here
} while (catch(IOException exc)); {

System.out.println ("Error reading file.");
}
try {
fin.close(); //filed closed
} catch (IOException e){
System.out.println ("Error closing file");
}
}

}} // end class ShowFile

#2:

/* Copy a XML file
* java CopyFile SECOND.Client-ServerFile.xml SECOND.Client-ServerFile.xml
*/

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.FileOutputStream;

public class CopyFile {

private static char ShowFile;
private static Object args;

private static void main (String arg[])
{

int c;
FileInputStream fin;
FileOutputStream fout;
char CopyFile;
char[] copyFrom = {ShowFile};

// Both files are specified above.
if (args.length != 2) {
System.out.println( "Usage: CopywFile From To");
return;
}

//open input file
try {
fin = new FileInputStream(args[0]);
} catch (FileNotFoundException exc){
System.out.println("Input File Not Found");
return;
}

//open output file
try {
fout = new FileOutputStream(args [1]);
} catch (FileNotFoundException exc){
System.out.println("Error Opening Output File");
}

// close output file
try {
fin.close();
} catch (FileNotFoundException exc2){
System.out.println("Error closing input file.");
return;
}

//Copy File
try {
do {
c = fin.read();
if (c!= -1) {
fout.write(c); //reads from 1 file and writes to other.
} //reads from 1 file and writes to other.
} while (c != -1);
} catch (FileNotFoundException exc) {
System.out.println ("Error");
}

try {
fin.close();
} catch (IOException exc){
System.out.println ("Error closing input file.");
}
try {
fout.close();
} catch (IOException exc){
System.out.println ("Error closing output file.");
}

} //end try
} //end class CopyFile
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-12-2008, 08:05 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,408
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Is this code written by yourself? Lots of errors there. Looping syntax, arguments and many more....
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on July 13, 2008)
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
help with these errors oceansdepth New To Java 3 04-16-2008 05:55 PM
Null array when passed to MouseListener stevemcc New To Java 2 04-02-2008 11:42 PM
Errors I don't understand MattyB New To Java 4 04-02-2008 12:55 AM
syntax error gabriel New To Java 3 08-03-2007 04:26 PM
Syntax error on token "(", ; expected baltimore AWT / Swing 1 08-01-2007 12:34 AM


All times are GMT +3. The time now is 04:32 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org