Parallelport-whts wrong with this code?

guys i need to know wht's wrong with this code.i sent the byte x=5 to the parallel port.and tried to read it back intoo another variable y..but the value of y is not returning.
it showed the errors:
1. printer port LPT1 :failed to write:IOException
2.Exception
java.io.IOException The device is not connected in writebyte
i have no devices connected to the parallel port.
my code is included:
import javax.comm.*;
import java.io.*;
public class Parallelio {
private static OutputStream outputStream;;
private static ParallelPort parallelPort;
private static CommPortIdentifier port;
private static InputStream inputStream;
// CONSTANT
public static final String PARALLEL_PORT = "LPT1";
public static void main(String[] args) {
try {
     // get the parallel port connected to the printer
port = CommPortIdentifier.getPortIdentifier(PARALLEL_PORT);
     // open the parallel port -- open(App name, timeout)
parallelPort = (ParallelPort) port.open("CommTest", 50);
outputStream = parallelPort.getOutputStream();
     byte x=5;     
     byte y;
     outputStream.write(x);
     inputStream=parallelPort.getInputStream();
     y=(byte)inputStream.read();
     System.out.println("The value read is:"+y);
     outputStream.flush();
     outputStream.close();     
// inputStream.flush();
     inputStream.close();     
     } catch (NoSuchPortException nspe) {
System.out.println("\nPrinter Port LPT1 not found : "
+ "NoSuchPortException.\nException:\n" + nspe + "\n");
} catch (PortInUseException piue) {
System.out.println("\nPrinter Port LPT1 is in use : "
+ "PortInUseException.\nException:\n" + piue + "\n");
     catch (IOException ioe) {
System.out.println("\nPrinter Port LPT1 failed to write : "
+ "IOException.\nException:\n" + ioe + "\n");
} catch (Exception e) {
System.out
.println("\nFailed to open Printer Port LPT1 with exeception : "
+ e + "\n");
} finally {
if (port != null && port.isCurrentlyOwned()) {
parallelPort.close();
System.out.println("Closed all resources.\n");
regards
arun
Message was edited by:
arun_koshy
Message was edited by:
arun_koshy
Message was edited by:
arun_koshy

Hi
I also need jwrapi package, could someone send me the binaries or the password?
My email is
[email protected]
thank you.

Similar Messages

  • DataOutputStream - whts wrong with this code!?!

    Hi
    I want to write a string to a file already existing on my phone.
    I used the following code but it throws a classNotFound and ConnectionNotFoundException
    I tried the follwoing 2 ways (I think theyr pretty much the same thing):
    1.
    String uri = "c:/documents/flash/my.txt";
    DataOutputSream dos = Connector.openDataOutputStream(uri);
    dos.writeUTF("hi");
    2.
    String uri = "c:/documents/flash/my.txt";
    OutputConnection conn = (OutputConnection)Connector.open(uri",Connector.WRITE);
    DataOutputStream dos = conn.openDataOutputStream();
    dos.writeUTF("hi");
    please can u tell me whts wrong with this or is the method itself that is wrong. how can I solve this... my basic purpose is to write a text to an existing file using a j2me application
    thanx
    Forum M Parmar

    Probably, there is no OutputConnection avalaible... writing files is not standard in j2me!

  • What is wrong with this code? on(release) gotoAndPlay("2")'{'

    Please could someone tell me what is wrong with this code - on(release)
    gotoAndPlay("2")'{'
    this is the error that comes up and i have tried changing it but it is not working
    **Error** Scene=Scene 1, layer=Layer 2, frame=1:Line 2: '{' expected
         gotoAndPlay("2")'{'
    Total ActionScript Errors: 1 Reported Errors: 1
    Thanks

    If you have a frame labelled "2" then it should be:
    on (release) {
        this._parent.gotoAndPlay("2");
    or other wise just the following to go to frame 2:
    on (release) {
         this._parent.gotoAndPlay(2);
    You just had a missing curly bracket...

  • I can't figure out what's wrong with this code

    First i want this program to allow me to enter a number with the EasyReader class and depending on the number entered it will show that specific line of this peom:
    One two buckle your shoe
    Three four shut the door
    Five six pick up sticks
    Seven eight lay them straight
    Nine ten this is the end.
    The error message i got was an illegal start of expression. I can't figure out why it is giving me this error because i have if (n = 1) || (n = 2) statements. My code is:
    public class PoemSeventeen
    public static void main(String[] args)
    EasyReader console = new EasyReader();
    System.out.println("Enter a number for the poem (0 to quit): ");
    int n = console.readInt();
    if (n = 1) || (n = 2)
    System.out.println("One, two, buckle your shoe");
    else if (n = 3) || (n = 4)
    System.out.println("Three, four, shut the door");
    else if (n = 5) || (n = 6)
    System.out.println("Five, six, pick up sticks");
    else if (n = 7) || (n = 8)
    System.out.println("Seven, eight, lay them straight");
    else if (n = 9) || (n = 10)
    System.out.println("Nine, ten, this is the end");
    else if (n = 0)
    System.out.println("You may exit now");
    else
    System.out.println("Put in a number between 0 and 10");
    I messed around with a few other thing because i had some weird errors before but now i have narrowed it down to just this 1 error.
    The EasyReader class code:
    // package com.skylit.io;
    import java.io.*;
    * @author Gary Litvin
    * @version 1.2, 5/30/02
    * Written as part of
    * <i>Java Methods: An Introduction to Object-Oriented Programming</i>
    * (Skylight Publishing 2001, ISBN 0-9654853-7-4)
    * and
    * <i>Java Methods AB: Data Structures</i>
    * (Skylight Publishing 2003, ISBN 0-9654853-1-5)
    * EasyReader provides simple methods for reading the console and
    * for opening and reading text files. All exceptions are handled
    * inside the class and are hidden from the user.
    * <xmp>
    * Example:
    * =======
    * EasyReader console = new EasyReader();
    * System.out.print("Enter input file name: ");
    * String fileName = console.readLine();
    * EasyReader inFile = new EasyReader(fileName);
    * if (inFile.bad())
    * System.err.println("Can't open " + fileName);
    * System.exit(1);
    * String firstLine = inFile.readLine();
    * if (!inFile.eof()) // or: if (firstLine != null)
    * System.out.println("The first line is : " + firstLine);
    * System.out.print("Enter the maximum number of integers to read: ");
    * int maxCount = console.readInt();
    * int k, count = 0;
    * while (count < maxCount && !inFile.eof())
    * k = inFile.readInt();
    * if (!inFile.eof())
    * // process or store this number
    * count++;
    * inFile.close(); // optional
    * System.out.println(count + " numbers read");
    * </xmp>
    public class EasyReader
    protected String myFileName;
    protected BufferedReader myInFile;
    protected int myErrorFlags = 0;
    protected static final int OPENERROR = 0x0001;
    protected static final int CLOSEERROR = 0x0002;
    protected static final int READERROR = 0x0004;
    protected static final int EOF = 0x0100;
    * Constructor. Prepares console (System.in) for reading
    public EasyReader()
    myFileName = null;
    myErrorFlags = 0;
    myInFile = new BufferedReader(
    new InputStreamReader(System.in), 128);
    * Constructor. opens a file for reading
    * @param fileName the name or pathname of the file
    public EasyReader(String fileName)
    myFileName = fileName;
    myErrorFlags = 0;
    try
    myInFile = new BufferedReader(new FileReader(fileName), 1024);
    catch (FileNotFoundException e)
    myErrorFlags |= OPENERROR;
    myFileName = null;
    * Closes the file
    public void close()
    if (myFileName == null)
    return;
    try
    myInFile.close();
    catch (IOException e)
    System.err.println("Error closing " + myFileName + "\n");
    myErrorFlags |= CLOSEERROR;
    * Checks the status of the file
    * @return true if en error occurred opening or reading the file,
    * false otherwise
    public boolean bad()
    return myErrorFlags != 0;
    * Checks the EOF status of the file
    * @return true if EOF was encountered in the previous read
    * operation, false otherwise
    public boolean eof()
    return (myErrorFlags & EOF) != 0;
    private boolean ready() throws IOException
    return myFileName == null || myInFile.ready();
    * Reads the next character from a file (any character including
    * a space or a newline character).
    * @return character read or <code>null</code> character
    * (Unicode 0) if trying to read beyond the EOF
    public char readChar()
    char ch = '\u0000';
    try
    if (ready())
    ch = (char)myInFile.read();
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    if (ch == '\u0000')
    myErrorFlags |= EOF;
    return ch;
    * Reads from the current position in the file up to and including
    * the next newline character. The newline character is thrown away
    * @return the read string (excluding the newline character) or
    * null if trying to read beyond the EOF
    public String readLine()
    String s = null;
    try
    s = myInFile.readLine();
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    if (s == null)
    myErrorFlags |= EOF;
    return s;
    * Skips whitespace and reads the next word (a string of consecutive
    * non-whitespace characters (up to but excluding the next space,
    * newline, etc.)
    * @return the read string or null if trying to read beyond the EOF
    public String readWord()
    StringBuffer buffer = new StringBuffer(128);
    char ch = ' ';
    int count = 0;
    String s = null;
    try
    while (ready() && Character.isWhitespace(ch))
    ch = (char)myInFile.read();
    while (ready() && !Character.isWhitespace(ch))
    count++;
    buffer.append(ch);
    myInFile.mark(1);
    ch = (char)myInFile.read();
    if (count > 0)
    myInFile.reset();
    s = buffer.toString();
    else
    myErrorFlags |= EOF;
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    return s;
    * Reads the next integer (without validating its format)
    * @return the integer read or 0 if trying to read beyond the EOF
    public int readInt()
    String s = readWord();
    if (s != null)
    return Integer.parseInt(s);
    else
    return 0;
    * Reads the next double (without validating its format)
    * @return the number read or 0 if trying to read beyond the EOF
    public double readDouble()
    String s = readWord();
    if (s != null)
    return Double.parseDouble(s);
    // in Java 1, use: return Double.valueOf(s).doubleValue();
    else
    return 0.0;
    Can anybody please tell me what's wrong with this code? Thanks

    String[] message = {
        "One, two, buckle your shoe",
        "One, two, buckle your shoe",
        "Three, four, shut the door",
        "Three, four, shut the door",
        "Five, six, pick up sticks",
        "Five, six, pick up sticks",
        "Seven, eight, lay them straight",
        "Seven, eight, lay them straight",
        "Nine, ten, this is the end",
        "Nine, ten, this is the end"
    if(n>0)
        System.out.println(message[n]);
    else
        System.exit(0);

  • Whath is wrong with this code???

    Whath is wrong with this code:
    import java.sql.*;
    class DataBaseConnexion
    Connection connexion;
    String url;
    DataBaseConnexion()
    {// 1-charger le driver JDBC-ODBC
    try
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    System.out.println("chargement du driver r�ussi");
    catch(ClassNotFoundException exc) {
    System.out.println("Erreur de chargement du pilote !");
    }// d�finir le pseudo URL pour joindre la BD
    url = "jdbc:odbc:cdi";//2- se connecter � la base de donn�es
    try {
    connexion = DriverManager.getConnection(url, "user_name", "pass_word");
    System.out.println("connexion r�ussie");
    catch(SQLException exc){
    System.out.println("Erreur 1 ! - " + exc.toString());
    public static void main(String Arg[])
    DataBaseConnexion db = new DataBaseConnexion();
    }//this errors occure
    File "C:\Documents and Settings\Administrateur\Bureau\DataBaseConnexion.java" Line 40: Syntax Error
    ---------------- JDK Release Build ------------------
    Compiling C:\Documents and Settings\Administrateur\Bureau\DataBaseConnexion.java
    C:\Documents and Settings\Administrateur\Bureau\DataBaseConnexion.java:40: 'class' or 'interface' expected
    public static void main(String Arg[])
    ^
    C:\Documents and Settings\Administrateur\Bureau\DataBaseConnexion.java:45: 'class' or 'interface' expected
    ^
    C:\Documents and Settings\Administrateur\Bureau\DataBaseConnexion.java:47: 'class' or 'interface' expected
    ^
    3 errors
    Finished

    I think you should remove the last closing curly brackets two lines above the main method.
    Regards

  • Fed up! dont know whats wrong with this code

    import java.io.*;
    import java.net.*;
    import java.awt.*;
    public class machine {
         private String machine_name;
         private String IP_address;
         public static void main(String[] args) throws IOException {
                   machine server = new machine();
                   server.machine_name = "SERVER1";
                   server.IP_address   = "192.168.0.1";
                   InputStreamReader reads_incoming = null;
                   // Reads incoming Bytes
                   PrintWriter sends_outgoing = null;
                   Socket ping_socket         = null;
                   try{
                        ping_socket = new Socket(server.machine_name , 7);
                        sends_outgoing = new PrintWriter(ping_socket.getOutputStream(),true);
                        reads_incoming = new InputStreamReader(ping_socket.getInputStream());
                   catch (UnknownHostException e){
                        //report error to sole text box
                   catch (IOException e)
                        //similar
                   /* Need a string to send some arbitrary bytes to SERVER1
                    * using IP_address instead , as this field in this implementation
                   while(true)
                        sends_outgoing.println(server.IP_address);
                        if(ping_socket.getInputStream() != null)
                             System.out.print("Server is up");
    }

    same... i am not very experienced, and try and uses this as training... but as new to java programming i could still mention about 5 things that might be wrong with this code... so a deeper explanation would be nice...
    while(true) { } for example seems like a nice way to make infinite loop that can suck your memory out of your computer pretty fast :-) newb

  • What the he** is wrong with this code?

    Hi,
    I have 2 tables. Primary table "resease" and secondary table (containing the foreign key) "kunden".
    Selecting a release (dropdownlist), will show you the corresponding entry of kunden (datatable).
    I added buttons to the datatable for deleting certain rows. This all works fine so far.
    But as you are going to delte the last entry of table kunden, I want to delte the corresponding entry of the table release as well. And by trying to do so, I get an exception telling in line "dataTable1Model.commit();"
    "java.sql.SQLException: Lock time out; try later."
    The exception disappears by deleting the inner try-catch block.
    So what is wrong with this code?
    Thank,
    Mark.
    PS: If you need the database-schema or anything else, let me know....
    public String delete_action() {
            try {
             //returns -1, so I can't use it     
                int rowCount = dataTable1Model.getRowCount();          
             //get affected row     
                com.sun.jsfcl.data.DataCache.Row row =
                dataTable1Model.getDataCache().get(dataTable1Model.getRowIndex());
                row.setDeleted(true);
                try {
                    //New RowSet for getting FK of affected line
                    JdbcRowSetXImpl pkRowSet = new JdbcRowSetXImpl();
                    pkRowSet.setDataSourceName("java:comp/env/jdbc/AVT");
                    pkRowSet.setCommand("SELECT fk_idrelease FROM kunden " +
                    "where fk_idrelease = ?");
                    //Convert Row into string
                    String myRow = row.toString();
                    //Getting the index of the first "=" (it's before the FK)
                    int index = myRow.indexOf("=")+1;
                    //Getting the number (FK) out of the string an casting it to int
                    int fk = Integer.parseInt(myRow.substring(index,(index+1)));
                    //Saving the FK in SessionBean1, so I can use it a parameter of
              //the setObject(int, Object)-method
                    getSessionBean1().setFk(fk);
                    //this will give me a RowSet of all lines containing the FK of
              //the affected row
              pkRowSet.setObject(1, getSessionBean1().getFk());
                    pkRowSet.execute();
                    pkRowSet.last();
                    int numRow = pkRowSet.getRow();
              //If the numRow (numbers of rows) is 1, go to cascade_delte
              //and delte the entry with primary key as well
                    if (numRow == 1) {
                        cascade_delete(); //not implemented yet
                }catch (Exception ex) {
                    error("Error counting affected rows: " + ex);
                dataTable1Model.commit();
                dataTable1Model.execute();
                info("Deleting row OK!");
            }catch (Exception e) {
                log("Page 1: Row delete exception: ", e);
                error("Error during deleting: " + e);
            } // end try catch
          return null;
        }

    just a guess - perhaps call pkRowSet.close() at the end of your try/catch?
    v

  • Contest: Guess whats wrong with this code!

    Can you guess whats wrong with this code snippet? Perhaps its too easy...
    private void clearDefaultTableModel( DefaultTableModel dtm) {    
            int  rowCount  = dtm.getRowCount();
            for(int i =0;  i < rowCount; i++) {
                dtm.removeRow(i);  
        }- Karl XII

    Can you guess whats wrong with this code snippet?
    Perhaps its too easy...
    private void clearDefaultTableModel(
    DefaultTableModel dtm) {    
    int  rowCount  = dtm.getRowCount();
    for(int i =0;  i < rowCount; i++) {
    dtm.removeRow(i);  
    it should be
    private void clearDefaultTableModel(DefaultTableModel dtm) {    
       int  rowCount  = dtm.getRowCount();
       for(int i =0;  i < rowCount; i++) {
         dtm.removeRow(0);  
    }or another way
    private void clearDefaultTableModel(DefaultTableModel dtm) {    
      while(dtm.getRowCount()>0){
         dtm.removeRow(0);  

  • HELP PLEASE - WHATS WRONG WITH THIS CODE

    Hi. I get this message coming up when I try to compile the code,
    run:
    java.lang.NullPointerException
    at sumcalculator.SumNumbers.<init>(SumNumbers.java:34)
    at sumcalculator.SumNumbers.main(SumNumbers.java:93)
    Exception in thread "main"
    Java Result: 1
    BUILD SUCCESSFUL (total time: 2 seconds)
    I am not sure whats wrong with the code. Any assistance would be nice. The code is below.
    package sumcalculator;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class SumNumbers extends JFrame implements FocusListener {
    JTextField value1;
    JTextField value2;
    JLabel equals;
    JTextField sum;
    JButton add;
    JButton minus;
    JButton divide;
    JButton multiply;
    JLabel operation;
    public SumNumbers() {
    SumNumbersLayout customLayout = new SumNumbersLayout();
    getContentPane().setFont(new Font("Helvetica", Font.PLAIN, 12));
    getContentPane().setLayout(customLayout);
    value1.addFocusListener(this);
    value2.addFocusListener(this);
    sum.setEditable(true);
    value1 = new JTextField("");
    getContentPane().add(value1);
    value2 = new JTextField("");
    getContentPane().add(value2);
    equals = new JLabel("label_1");
    getContentPane().add(equals);
    sum = new JTextField("");
    getContentPane().add(sum);
    add = new JButton("+");
    getContentPane().add(add);
    minus = new JButton("-");
    getContentPane().add(minus);
    divide = new JButton("/");
    getContentPane().add(divide);
    multiply = new JButton("*");
    getContentPane().add(multiply);
    operation = new JLabel();
    getContentPane().add(operation);
    setSize(getPreferredSize());
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    public void focusGained(FocusEvent event){
    try {
    float total = Float.parseFloat(value1.getText()) +
    Float.parseFloat(value2.getText());
    sum.setText("" + total);
    } catch (NumberFormatException nfe) {
    value1.setText("0");
    value2.setText("0");
    sum.setText("0");
    public void focusLost(FocusEvent event){
    focusGained(event);
    public static void main(String args[]) {
    SumNumbers window = new SumNumbers();
    window.setTitle("SumNumbers");
    window.pack();
    window.show();
    class SumNumbersLayout implements LayoutManager {
    public SumNumbersLayout() {
    public void addLayoutComponent(String name, Component comp) {
    public void removeLayoutComponent(Component comp) {
    public Dimension preferredLayoutSize(Container parent) {
    Dimension dim = new Dimension(0, 0);
    Insets insets = parent.getInsets();
    dim.width = 711 + insets.left + insets.right;
    dim.height = 240 + insets.top + insets.bottom;
    return dim;
    public Dimension minimumLayoutSize(Container parent) {
    Dimension dim = new Dimension(0, 0);
    return dim;
    public void layoutContainer(Container parent) {
    Insets insets = parent.getInsets();
    Component c;
    c = parent.getComponent(0);
    if (c.isVisible()) {c.setBounds(insets.left+24,insets.top+48,128,40);}
    c = parent.getComponent(1);
    if (c.isVisible()) {c.setBounds(insets.left+256,insets.top+48,128,40);}
    c = parent.getComponent(2);
    if (c.isVisible()) {c.setBounds(insets.left+408,insets.top+48,56,40);}
    c = parent.getComponent(3);
    if (c.isVisible()) {c.setBounds(insets.left+488,insets.top+48,152,40);}
    c = parent.getComponent(4);
    if (c.isVisible()) {c.setBounds(insets.left+128,insets.top+136,72,40);}
    c = parent.getComponent(5);
    if (c.isVisible()) {c.setBounds(insets.left+248,insets.top+136,72,40);}
    c = parent.getComponent(6);
    if (c.isVisible()) {c.setBounds(insets.left+368,insets.top+136,72,40);}
    c = parent.getComponent(7);
    if (c.isVisible()) {c.setBounds(insets.left+488,insets.top+136,72,40);}
    c = parent.getComponent(8);
    if (c.isVisible()) {c.setBounds(insets.left+176,insets.top+48,56,40);}
    }

    Thank you. How do i amend this? I have defined value1though.Yes, you did - but after the call to addFocusListener(...). It needs to be before it.
    BTW, you did the same thing with "value2.addFocusListener(this)" and "sum.setEditable(true)" on the next two lines. You're attempting to call a method on an object that doesn't exist yet (i.e., you haven't called new yet).

  • What's wrong with this code (AS3)?

    I want to publish a live stream and, when a button is pressed, publish the same stream for vod.  I haven't been able to get an answer as to whether I can do this...my code is below.  Can someone please tell me if I can do this, or what may be wrong with my code?
    The live stream and playback works fine; but the recording doesn't start.  Also, I want other objects on the client, such as the current camera and audio information, and the aspect ratio being used.  I havent' been able to get these to show up (i.e., the incomingLbl and outgoingLbl do not show up).
    Thank you,
    Phillip A
    My code:
    package {
        import flash.display.MovieClip;
        import flash.net.NetConnection;
        import flash.events.NetStatusEvent; 
        import flash.events.MouseEvent;
        import flash.events.AsyncErrorEvent;
        import flash.net.NetStream;
        import flash.media.Video;
        import flash.media.Camera;
        import flash.media.Microphone;
        import fl.controls.Button;
        import fl.controls.Label;
        import fl.controls.TextArea;
        import fl.controls.CheckBox;
        public class vodcast1 extends MovieClip {
            private var nc:NetConnection;
            private var nc2:NetConnection;
            private var ns:NetStream;
            private var ns2:NetStream;
            private var nsPlayer:NetStream;
            private var vid:Video;
            private var vidPlayer:Video;
            private var cam:Camera;
            private var mic:Microphone;
            private var camr:Camera;
            private var micr:Microphone;
            private var clearBtn:Button;
            private var startRecordBtn:Button;
            private var outgoingLbl:Label;
            private var incomingLbl:Label;
            private var myMetadata:Object;
            private var outputWindow:TextArea;
            private var cb1:CheckBox;
            public function vodcast1(){
                setupUI();
                nc = new NetConnection();
                nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
                nc.connect("rtmp://localhost/publishLive");
                nc2 = new NetConnection();
                nc2.connect("rtmp://localhost/vod/videos");
                nc2.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus2);
            private function startRecordHandler(event:MouseEvent):void {
                publishRecordStream();
            private function onNetStatus(event:NetStatusEvent):void {
                trace(event.target + ": " + event.info.code);
                switch (event.info.code)
                    case "NetConnection.Connect.Success":
                        trace("Congratulations! you're connected to live");
                        publishCamera();
                        displayPublishingVideo();
                        displayPlaybackVideo();
                        break;
                    case "NetStream.Publish.Start":
            // NetStatus handler for Record stream       
            private function onNetStatus2(event:NetStatusEvent):void {
                trace(event.target + ": " + event.info.code);
                switch (event.info.code)
                    case "NetConnection.Connect.Success":
                        trace("Congratulations! you're connected to vod");                   
                        break;
                    case "NetConnection.Connect.Rejected":
                    case "NetConnection.Connect.Failed":
                    trace ("Oops! the connection was rejected");
                        break;
                    case "NetStream.Publish.Start":
                        sendMetadata();
                        break;
            private function asyncErrorHandler(event:AsyncErrorEvent):void {
                trace(event.text);
            private function sendMetadata():void {
                trace("sendMetaData() called")
                myMetadata = new Object();
                myMetadata.customProp = "Recording in progress";
                ns.send("@setDataFrame", "onMetaData", myMetadata);
            private function publishRecordStream():void {
                camr = Camera.getCamera();
                micr = Microphone.getMicrophone();
                ns2 = new NetStream(nc2);
                ns2.client = new Object();
                ns2.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus2);
                ns2.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
                ns2.attachCamera(camr);
                ns2.attachAudio(micr);
                ns2.publish("vodstream", "record");           
            private function publishCamera():void {
                cam = Camera.getCamera();
                mic = Microphone.getMicrophone();
                ns = new NetStream(nc);
                ns.client = this;
                ns.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
                ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
                ns.attachCamera(cam);
                ns.attachAudio(mic);
                ns.publish("livestream", "live");
            private function displayPublishingVideo():void {
                vid = new Video(cam.width, cam.height);
                vid.x = 10;
                vid.y = 30;
                vid.attachCamera(cam);
                addChild(vid); 
            private function displayPlaybackVideo():void {
                nsPlayer = new NetStream(nc);
                nsPlayer.client = this;
                nsPlayer.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
                nsPlayer.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
                nsPlayer.play("livestream");
                vidPlayer = new Video(cam.width, cam.height);
                vidPlayer.x = cam.width + 100;
                vidPlayer.y = 30;
                vidPlayer.attachNetStream(nsPlayer);
                addChild(vidPlayer);
            private function setupUI():void {
                outputWindow = new TextArea();
                outputWindow.move(250, 175);
                outputWindow.width = 200;
                outputWindow.height = 50;
                outgoingLbl = new Label();
                incomingLbl = new Label();
                outgoingLbl.width = 100;
                incomingLbl.width = 100;
                outgoingLbl.text = "Publishing Stream";
                incomingLbl.text = "Playback Stream";
                outgoingLbl.move(20, 200);
                incomingLbl.move(300, 200);
                outgoingLbl.condenseWhite = true;
                incomingLbl.condenseWhite = true;
                startRecordBtn = new Button();
                startRecordBtn.width = 150;
                startRecordBtn.move(250, 345);
                startRecordBtn.label = "Start Recording";
                startRecordBtn.addEventListener(MouseEvent.CLICK, startRecordHandler);
                //cb1 = new CheckBox();
                //cb1.label = "Record";
                //cb1.move(135,300);
                //cb1.addEventListener(MouseEvent.CLICK,publishRecordStream);
                //clearBtn = new Button();
    //            clearBtn.width = 100;
    //            clearBtn.move(135,345);
    //            clearBtn.label = "Clear Metadata";
    //            clearBtn.addEventListener(MouseEvent.CLICK, clearHandler);
                addChild(outgoingLbl);
                addChild(incomingLbl);
    //            addChild(clearBtn);
                addChild(startRecordBtn);
    //            addChild(cb1);
                addChild(outputWindow);
            public function onMetaData(info:Object):void {
                outputWindow.appendText(info.customProp);

    use event.currentTarget (and you don't need to repeatedly define the same function):
    var c:int;
    var buttonName:String;
    for (c = 1;c < 5;c++) {
         buttonNum = "button"+c;
         this[buttonNum].addEventListener(MouseEvent.MOUSE_DOWN, pressStepButton);
    function pressStepButton(event:MouseEvent) {          trace(event.currentTarget,event.currentTarget.name);     }

  • What's wrong with this code (in recursion there may be a problem )

    // ELEMENTS OF TWO VECTORS ARE COMPARED HERE
    // CHECK WHAT IS WRONG WITH THIS PGM
    // there may be a problem in recursion
    import java.util.*;
    class Test
    Vector phy,db;
    public static void main(String adf[])
         Vector pp1=new Vector();
         Vector dp1=new Vector();
         //adding elements to the vector
         pp1.add("1");
         pp1.add("a");
         pp1.add("b");
         pp1.add("h");
         pp1.add("c");
         dp1.add("q");
         dp1.add("c");
         dp1.add("h");
         dp1.add("w");
         dp1.add("t");
         printVector(dp1);
         printVector(pp1);
         check2Vectors(pp1,dp1);
    public static void printVector(Vector v1)
         System.out.println("Vector size "+v1.size());
         for(int i=0;i<v1.size();i++)
              System.out.println(v1.get(i).toString());
    public static void check2Vectors(Vector p,Vector d)
         System.out.println("p.size() "+p.size()+" d.size() "+d.size());
         printVector(p);
         printVector(d);
         for(int i=0;i<p.size();i++)
                   for(int j=0;j<d.size();j++)
                        System.out.println(" i= "+i+" j= "+j);
                        Object s1=p.elementAt(i);
                        Object s2=d.elementAt(j);
              System.out.println("Checking "+s1+" and "+s2);
                        if(s1.equals(s2))
    System.out.println("Equal and Removing "+s1+" and "+s2);
                             p.remove(i);
                             d.remove(j);
                             printVector(p);
                             printVector(d);                    
                        check2Vectors(p,d);
                   }//inner for
              }//outer for     
    if(p.size()==0||d.size()==0)
    System.out.println("Vector checking finished and both match");
    else
    System.out.println("Vector checking finished and both do not match");
    }//method
    }

    hi,
    but the upper limit is changing everytime you call the function recursively
    so there should not be any problem(i suppose)
    my intension is to get the unmatched elements of the two vectors
    suggest me changes and thanks in advancce
    ashok
    The problems comes from the fact that you remove
    elements for a Vector while iterating in a loop where
    the upper limit as been set to the initial size of the
    Vector.
    You should use so while loops with flexible stop
    conditions that would work when the size of the Vector
    changes.
    Finally: why don't you use Vector.equals() ?

  • FileFilter????What's wrong with this code???HELP!!

    I want to limit the JFileChooser to display only txt and java file. But the code I wrote has error and I don't know what's wrong with it. can anyone help me to check it out? Thank you.
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class FileFilterTest extends JPanel
         public static void main(String[] args)
              new FileFilterTest();
         public class fFilter implements FileFilter
              public boolean accept(File file)
                   String name = file.getName();
                   if(name.toLowerCase().endsWith(".java") || name.toLowerCase().endsWith(".txt"))
                        return true;
                   else
                        return false;
         public FileFilterTest()
              JFileChooser fc = new JFileChooser();
              fc.setFileFilter(new fFilter());
              fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
              fc.setCurrentDirectory(new File(System.getProperty("user.dir")));
              //fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
              //fc.setMultiSelectionEnabled(true);
              int returnVal = fc.showDialog(FileFilterTest.this, "Open File");
              if(returnVal == JFileChooser.APPROVE_OPTION)
                   String file = fc.getSelectedFile().getPath();
                   if(file == null)
                        return;
              else if(returnVal == JFileChooser.CANCEL_OPTION)
                   System.exit(0);
              else
                   System.exit(0);
              JFrame f = new JFrame();
              FileFilterTest ff = new FileFilterTest();
              f.setTitle("FileFilterTest");
              f.setBackground(Color.lightGray);
              f.getContentPane().add(ff, BorderLayout.CENTER);
              f.setSize(800, 500);
              f.setVisible(true);
    }

    There are two file filters
    class javax.swing.filechooser.FileFilter
    interface java.io.FileFilter
    In Swing you need to make a class which extends the first one and implements the second. Sometimes you may not need to implement the second, but it is more versitle to do so and requires no extra work.

  • Whats Wrong with this code? URLReader

    Ok, so I have this URLReader.java program. It goes to a specific website, I put in a project ID. It pulls up a project. I can then "Scrape", "Extract Data from the URL and put them into variables. I then upload the variables into the DB.
    I've used this code over and over again and it works, but I seem to have a problem with the second part of the code.The error message that I get is:
    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
    Please note the URL is a fake one. I did not want to give the real URL. I have provided the String to read, which is actually HTML code. I thought it might be the "Researchers(s):" string that it does like, maybe a problem with "(s), but I dont know?
    First part of the code: This really gets a project ID from a collection and iterates throught the collection with each project ID.
    String projectId = "87023";
                java.net.URL projectDetails = new  java.net.URL("http://someSite.com/portfolio/ProjectDetails.asp?Source=Tracking&Key="+projectId);
                java.io.BufferedReader in =
                            new java.io.BufferedReader(new java.io.InputStreamReader(projectDetails.openStream()));
                String projDetailspage = new String("");
                String inputLine = "";
                while ((inputLine = in.readLine()) != null)
                    projDetailspage = projDetailspage.concat(inputLine.trim());
                System.out.println("project ID: "+ projectId);
    Second Part of the Code:
    String str = (projDetailspage.split("\\<[Bb]\\>Researcher(s)\\</[Bb]\\>")  //  look for: <b>Researcher(s):</b> , also the part of code I am having problems with.
                [1].split( "\\<td\\>")[1].split("\\</table>")[0].trim());   //put everything into a variable call str from the <td> to the </table> tags 
                System.out.println("String before replace all: "+ str);
    The HTML code to read and search through:<!-- researchers -->
        <tr>
              <td width="30%" align="right" valign="top">
                   <font size="-1">
                   <b>Researcher(s):</b>
                   </font>
              </td>
                  <td width="70%" align="left" valign="top">
                        <font size="-1">
                        Dr. Michael E. Welge, University of Illinois at Urbana-Champaign
                        </font>
                   </td>
                   </tr>
                            <tr>
                                  <td width="30%">
                                       <font size="-1">
                                       </font>
                                  </td>
                                <td width="70%" align="left" valign="top">
                                       <font size="-1">
                                       Dr. Albert J. Valocchi, University of Illinois at Urbana-Champaign
                                       </font>
                                  </td>
                            </tr>
                            <tr>
                                  <td width="30%">
                                       <font size="-1">
                                       </font>
                                  </td>
                                <td width="70%" align="left" valign="top">
                                       <font size="-1">
                                       Dr. Barbara Ann Bailey, University of Illinois at Urbana-Champaign
                                       </font>
                                  </td>
                            </tr>
                            <tr>
                                  <td width="30%">
                                       <font size="-1">
                                       </font>
                                  </td>
                                <td width="70%" align="left" valign="top">
                                       <font size="-1">
                                       Dr. David E. Goldberg, University of Illinois at Urbana-Champaign
                                       </font>
                                  </td>
                            </tr>
         <!-- students -->
        <tr>
              <td width="30%" align="right" valign="top">
                   <font size="-1">
                   <b>Student(s):</b>
                   </font>
              </td>
                   <td width="70%" align="left" valign="top">
                        <font size="-1">
                        None Found
                        </font>
                   </td>
              </tr>
              </table>
              </td>
         </tr>
         </table>
         </td>
    </tr>
    </table>

    camickr
    I ran your program and it works great. This is the output I get. This is for a project that had 4 researchers, that is not always the case.
    investigator1 = r. Michael E. Welge
    investigator2 = Dr. Albert J. Valocchi
    investigator3 = Dr. Barbara Ann Bailey
    investigator4 = Dr. David E. Goldberg
    for some reason I loose the D in Dr. for the first Investigator.
    also, I know I need to modify my code to find out how many researchers there are. I then place them into the correct variable.
    example
    researchers String that your code works on: None Found</font></td></tr><!-- students --><tr><td width="30%" align="right" valign="top"><font size="-1"><b>Student(s):</b></font></td><td width="70%" align="left" valign="top"><font size="-1">Dr. Terry Hogan, Pennsylvania State University</font></td></tr><tr><td width="30%"><font size="-1"></font></td><td width="70%" align="left" valign="top"><font size="-1">Dr. Chengyu Shen, Pennsylvania State University</font></td></tr><tr><td width="30%"><font size="-1"></font></td><td width="70%" align="left" valign="top"><font size="-1">Dr. Anne Pifer, Pennsylvania State University</font></td></tr>
    investigator1 = one Found|Student(s):|Dr. Terry Hogan  // should be None Found.
    investigator2 = Dr. Chengyu Shen
    investigator3 = Dr. Anne Pifer
    npe errorjava.lang.ArrayIndexOutOfBoundsException: 3
    The logic should be, when I scrape between tags, if it should be "None Found" then skip to the next project ID , also, each project may have as many as 0, 1, 2, 3, 4 researchers. but no more than 4
    So I thought of doing an:
    If( researchers == 2)
        investigator1 = investigator[x];
        investigator2 = investigator[x];
    }etc...
    Thanks again.
    if you need me to email you the code. my email addres is [email protected]
    I know I am not that talented of a programmer, but I am learning, and trying all the time. I want to do this the correct way, but I am not always sure which way that is. I usually try a class Diagram and go from there, but I have had some trouble with this one. If you need more of an explanation then email me.
    orozcom

  • Help!!! What's wrong with this code. JSP page can't retrieve properties.

    I'v got a piece of code that was created to send some parameters to JSP page via POST method. But in server page I can't retrieve this parameters, please help me and try to find "main" bug in this code.
    try {
    URL url = new URL("http://localhost/index.jsp");
    HttpURLConnection httpCon = (HttpURLConnection)url.openConnection();
    httpCon.setRequestMethod( "POST" );
    httpCon.setDoOutput( true );
    String body = URLEncoder.encode("name=Oleg", "UTF-8");
    httpCon.setRequestProperty( "Content-length", Integer.toString( outBody.length() ));
    httpCon.setRequestProperty( "Content-type", "application/x-www-form-urlencoded" );
    OutputStream os = httpCon.getOutputStream();
    PrintWriter ow = new PrintWriter( os );
    ow.print( body );
    ow.flush();
    ow.close();
    } catch (....) {
    }

    Hi
    You must not encode all the body just the values of the parameters.
    You can do as following in order to send a post request with 2 parameters
    String param1 = "Co & sons";
    String param2 = "ltd.";
    String encParam1 = URLEncoder.encode(param1,"UTF-8");
    String encParam2 = URLEncoder.encode(param2,"UTF-8");
    String body = "param1="+encParam1+"&param2="+encParam2;
    OutputStream os = httpCon.getOutputStream();
    PrintWriter ow = new PrintWriter( os );
    ow.print( body );
    ow.flush();
    //read the response from the jsp
    InputStream inS = httpCon.getInputStream();
    byte[] buff = new byte[5000];
    StringBuffer sbuff = new StringBuffer();
    int nrBytes ;
    while( (nrBytes = inS.read(buff, 0, 5000))!=-1) {
      sbuff.append(new String(buff,0,nrBytes));
    inS.close();
    ow.close();
    ...This is the jsp page which gets the parameters
    <%
         String param1 = request.getParameter("param1");
         param1 = new String(param1.getBytes(),"utf-8");
         String param2 = request.getParameter("param2");
         param2 = new String(param2.getBytes(),"utf-8");
    %>I hope I helped you.
    Regards,
    BG

  • Crop Functio... what is wrong with this code???

    Hi all,
    I have created this method to crop my bufferedimage, but when i call it it does not seem to do anything. :(
    Can anyone see what is wrong with it please?
    Thank you for you help!
    Claire
    x
         public BufferedImage cropImage()
              mBufferedImageCrop = copy(mBufferedImage);
              Graphics grphc = mBufferedImageCrop.getGraphics();
              Rectangle desiredArea = new Rectangle(10,10,10,10);
              BufferedImage sub_bi = mBufferedImageCrop.getSubimage(desiredArea.x, desiredArea.y,
                                                                                 desiredArea.width, desiredArea.height);
              grphc = mBufferedImageCrop.getGraphics();
              grphc.drawImage(sub_bi, desiredArea.x, desiredArea.y, this);
              repaint();
              return sub_bi;
         }I call this method using:
    displayPanel.cropImage();
    displayPanel.validate();
    repaint();Thanx

    I worked out the problem!
    :)

Maybe you are looking for

  • OHD filename details

    Hi Gurus, I am currently generating a file, through a Process chain, from OHD that contains the BW system timestamp as part of its logical filename. There is a requirement to log the file name generated along with the number of rows.. Is there anyway

  • In a loop to put in password into yahoo games even though I am signed into Yahoo for my email

    I deleted some cookies in yahoo. Now when I am signed into yahoo and try to play a Yahoo game I get stuck in a loop where I am being asked to enter my password. I have reset my password. I have even created a new account and password. Nothing is work

  • IE11 Windows 7 SP1 Home Premium - frequent waits

    IE11 with current Windows 7 SP1 Home Premium 64bit - Yesterday I allowed Windows Update to upgrade IE10 to IE11.  Since that upgrade, when I'm using IE11, my fast desktop PC has MANY frequent little "waits", where the little spinning circle appears o

  • When I double-click on a song name, a different song plays. Did I transfer my library to my new computer wrong?

    I recently transfered my entire song library from an external drive to my new HP computer with Windows 8 and also copied over the library file.  I have the usual issues of iTunes not being able to locate some of my songs (indicated by a !), even thou

  • CCMS: Determining warning messages from CCMS

    Hi! We use SAP Solution Manager 4.0, SPS 13 for System Monitoring of almost 100 systems. We configured SOLMAN as CEN system and activated the CCMSPING with –push option. For almost the 2/3 of the systems we configured SAPCCM4X agents. Our current pro