Misbehaving code

The code
class Test
     static public void main(String[] args)
          try
               String[] command = {"text2pdf",  "file.txt", ">", "file.pdf"};
               Runtime.getRuntime().exec(command);
          catch(Exception e)
               e.printStackTrace();
}is misbehaving by not producing the expected file. However, the command
text2pdf file.txt > file.pdfdirectly on my command line produces the file. What issues reside here?

Jamwa wrote:
import java.io.*;
class Test
     static public void main(String[] args)
          try
               Runtime rt = Runtime.getRuntime();
               String contents = "";
               // create the text file
               String command = "text2pdf tables.txt";
               Process proc = rt.exec(command);
               InputStream stdin = proc.getInputStream();
               InputStreamReader isr = new InputStreamReader(stdin);
               BufferedReader br = new BufferedReader(isr);
               String line = null;
               while ( (line = br.readLine()) != null)
                    contents += br.readLine();
               File output = new File("file.pdf");
               FileOutputStream fos = new FileOutputStream(output);
               fos.write(contents.getBytes());
               fos.close();
          catch(Exception e)
               e.printStackTrace();
}is my review of the code.
Acrobat reader, however, complains that
'Adobe Reader could not open file.pdf because it is either not a supported file type or because the file has been damaged...'Thats because the String contents is just that. A String. You are writing the bytes of a String to a file with a PDF extension and trying to open it in Adobe.
Of course it is not going to work because the String bytes don't constitute a PDF file format.
That String contents is merely the console output for your text2pdf program.

Similar Messages

  • Stopping a simple Thread

    I read the article http://download.oracle.com/javase/6/docs/technotes/guides/concurrency/threadPrimitiveDeprecation.html but it did not helped me much.
    Here is a simple scenario that I'm unable to solve.
    Consider a misbehaving thread:
    public class Nano extends Thread {
         @Override
         public void run() {
              while(true) {
                   System.out.println(System.nanoTime());
    Assume that the class above is a third party tool and I cannot modify it. (Eg. I cannot add a flag to the loop like - while(keepRunning))
    I create a class to run this misbehaving thread, and try to KILL it after a certain timeout:
    public class MyThreadDemo {
         public static void main(String[] args) {
              Thread t = new Nano();
              System.out.println("Starting the new thread");
              t.start();
              // Some operation
              t.interrupt();
              System.out.println("Thread is now Stopped. Terminating Application.");
    Well, the message "Terminating Application" is printed, but the thread Nano keeps running for ever.
    Can you suggest a possible solution, a safe way to stop the thread?

    837595 wrote:
    I read the article http://download.oracle.com/javase/6/docs/technotes/guides/concurrency/threadPrimitiveDeprecation.html but it did not helped me much.
    Here is a simple scenario that I'm unable to solve.
    Consider a misbehaving thread:
    public class Nano extends Thread {
         @Override
         public void run() {
              while(true) {
                   System.out.println(System.nanoTime());
    }Assume that the class above is a third party tool and I cannot modify it. (Eg. I cannot add a flag to the loop like - while(keepRunning))
    I create a class to run this misbehaving thread, and try to KILL it after a certain timeout:
    public class MyThreadDemo {
         public static void main(String[] args) {
              Thread t = new Nano();
              System.out.println("Starting the new thread");
              t.start();
              // Some operation
              t.interrupt();
              System.out.println("Thread is now Stopped. Terminating Application.");
    }Well, the message "Terminating Application" is printed, but the thread Nano keeps running for ever.
    Can you suggest a possible solution, a safe way to stop the thread?Run it in a separate JVM.
    You want two threads in the new JVM.
    One control thread that interacts with your original app in the original JVM.
    One daemon thread that runs the misbehaving code.
    When your original app in your original JVM tells the control thread in the new JVM to exit
    there will only be a daemon thread left and the JVM will exit.

  • Odd error originating from NI-5411 (Error code: BFFA0002) when trying to load arbitrary waveform

    Hello everyone. 
    We have some equipment (PCI NI-5411) that is misbehaving in an odd and new way. When trying to load an arbitrary waveform onto the AWG (using a library call to the "niFgen Write Binary 16 Waveform"), it produces an error. The error code is "BFFA0002", but I haven't been able to find any information that can show what this error code provides. Previously, we had some problem when the system wouldn't find the file and produces an error even though the file is there. After changing our code so the file access is attempted several times, the problem was resolved. However, that doesn't work in this case and we do not know here the problem is.
    This is a pretty much shooting wild and hoping that something falls down, but if anyone could provide me with information about the error code or another probable error source I would be highly grateful.
    Thanks in advance!
    With best regards,
    Niclas

    Hi Niclas,
    That error code suggests that a file cannot be opened. This error is defined in IVI as  IVI_ERROR_CANNOT_OPEN_FILE.I don't think we return this error code from the NI-FGEN driver.
    You mentioned that you have an issue with finding a file. Is that file specific to your application? How is it being open or used? What API do you use to open that file?
    For NI-FGEN specific error code (and generic IVI error codes), you can query the error message by calling niFgen_error_message function or niFgen Error Message.vi.
    Thanks,
    - Liusdi

  • Why is the Tick Count function slow when used with a .dll but fine with normal lab view code?

    when using the Tick Count millisecond timer with a .dll I've written in C, I'm getting some odd timing issues.
    When I code the function I want (I'll explain it below in case it helps) in LV and run it as a subVI, feeding it the Tick count as an argument, the function runs quickly, but not quite as quickly as I would like. When I feed this same subVI just an integer constant rather than the Tick Count, it takes about the same amount of time, maybe a tiny bit more on average.
    When I bring in my function from a .dll, however, I start to run into problems. When I feed my function an integer constant, it is much faster than my subVI written in LV. When I feel my .dll the Tick Count, however, it slows down tremendously. I'm including a table with the times below:
                 |  Clock   |   Constant   |
    SubVi:   | 450ms  |  465ms       |
    .dll         | 4900ms|  75ms         |
    This is running the function 100,000 times. The function basically shifts the contents of a 2-dimensional array one place. For this function, it probably won't be a huge deal for me, but I plan on moving some of my other code out of LV and into C to speed it up, so I'd really like to figure this out.
    Thanks,
    Aaron

    Hi Aaron,
    Thanks for posting the code -- that made things a lot clearer for me. I believe I know what's going on here, and the good news is that it's easy to correct! (You shouldn't apologize for this though, as even an experienced LabVIEW programmer could run into a similar situation.) Let me explain...
    When you set your Call Library Function Node to run in the UI Thread you're telling LabVIEW that your DLL is not Thread-safe -- this means that under no circumstances should the DLL be called from more than one place at a time. Since LabVIEW itself is inherently multithreaded the way to work with a "thread-unsafe" DLL is to run it in a dedicated thread -- in this case, the UI thread. This safety comes at a price, however, as your program will have to constantly thread-swap to call the DLL and then execute block diagram code. This thread-swapping can come with a performance hit, which is what you're seeing in your application.
    The reason your "MSTick fine behavior.vi" works is that it isn't swapping threads with each iteration of the for loop -- same with the "MSTick bad behavior.vi" without the Tick Count function. When you introduce the Tick Count Function in the for loop, LabVIEW now has to swap threads every single iteration -- this is where your performance issues originate. In fact, you could reproduce the same behavior with any function (not just TIck Count) or any DLL. You could even make your "MSTick fine behavior.vi" misbehave by placing a control property node in the for loop. (Property nodes are also executed in the UI thread).
    So what's the solution? If your DLL is thread-safe, configure the call library function node to be "reentrant." You should see a pretty drastic reduction in the amount of time it takes your code to execute. In general, you can tell if your DLL is thread-safe when:
    The code is thread safe when it does not store any global data, such as global variables, files on disk, and so on.
    The code is thread safe when it does not access any hardware. In other words, the code does not contain register-level programming.
    The code is thread safe when it does not make any calls to any functions, shared libraries, or drivers that are not thread safe.
    The code is thread safe when it uses semaphores or mutexes to protect access to global resources.
    The code is thread safe when it is called by only one non-reentrant VI.
    There are also a few documents on the website that you may want to take a look at, if you want some more details on this:
    Configuring the Call Library Function Node
    An Overview of Accessing DLLs or Shared Libraries from LabVIEW
    VI Execution Speed
    I hope this helps clear-up some confusion -- best of luck with your application!
    Charlie S.
    Visit ni.com/gettingstarted for step-by-step help in setting up your system

  • Certain codes in the stocks widget no longer work

    Hi,
    I use the Stocks widget to track currency exchange rates. Certain stock codes such as
    USDZAR=X (US Dollar to S.African Rand)
    GBPZAR=X (UK Pound to S.African Rand)
    EURZAR=X (Euro to S.African Rand)
    still work fine, but others stopped producing results a few months ago, such as:
    XAUUSD=X (gold price in dollars)
    ARSZAR=X (Argentine Peso to S.African Rand)
    These stock codes validate OK, get added to the widget OK, and the graphs work OK, but the current value does not display any longer, as they still do for the other stocks.
    I believe that it is the feed that is at fault, as the above stocks misbehave in exactly the same way on my iPhone, regardless of the many, many Macs I have tried it on.
    Can anyone shed any light on this?

    Thanks for the prompt reply edmeister,
    Your suggested fix made no difference and Talk Talk webmail still not working.
    I:
    Created alternative profiles;
    Exported and Imported bookmarks - following all the instructions on mozillazine.
    And:
    FF 3.6 asks me to choose profile - fine;
    But FF4 does not ask for profile selection.
    I think the problem lies somewhere within the FF4 and Talk Talk webmail box. Back to you for your best efforts and any further advice. Thanks.
    Ian

  • Unable to select US area code

    I am trying to set up a Skype number.  I selected the US and can select a state without any problem but no matter which state I select, the drop down list of area codes is empty.  How do I get around this problem?

    Hi, Adiajohn, and welcome to the Community,
    I know this is a very no-tech or low-tech suggestion, however here goes: please try again, this time using a different web browser than you normally use.  For whatever reason, when the Skype website misbehaves, this often solves whatever problem is keeping the website from rendering properly.
    If this still does not do it, please post back to let us know!  Thanks!
    Kind regards,
    Elaine
    Was your question answered? Please click on the Accept as a Solution link so everyone can quickly find what works! Like a post or want to say, "Thank You" - ?? Click on the Kudos button!
    Trustworthy information: Brian Krebs: 3 Basic Rules for Online Safety and Consumer Reports: Guide to Internet Security Online Safety Tip: Change your passwords often!

  • Help for code

    I am unable to recognize the problem in the following code. My paint() in defined in a class ImagePanel and I am unable to access paint() from outside.
    Please Help!
    import javax.swing.*;
    import javax.swing.event.*;
    import java.io.*;
    import javax.media.*;
    import javax.media.format.*;
    import javax.media.util.*;
    import javax.media.control.*;
    import javax.media.protocol.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.image.*;
    import java.awt.event.*;
    import com.sun.image.codec.jpeg.*;
    import javax.media.*;
    import javax.media.protocol.*;
    import javax.media.control.*;
    import javax.media.format.*;
    import javax.media.util.BufferToImage;
    import java.io.IOException;
    import java.net.*;
    import java.awt.*;
    ////////////////////FROM GESTURE
    import java.io.*;
    import java.awt.*;
    import java.awt.image.*;
    import java.applet.*;
    import java.util.*;
    import java.lang.*;
    //import Gesture.class;
    import com.sun.image.codec.jpeg.*;
    import sun.awt.image.BufferedImageGraphics2D;
    public class SwingCapture extends Panel implements ActionListener, Runnable { 
    public static Player player = null; 
    public CaptureDeviceInfo di = null; 
    public MediaLocator ml = null; 
    public JButton capture = null; 
    public Buffer buf = null; 
    public Image img = null; 
    //public VideoFormat vf=null
    public BufferToImage btoi = null; 
    public ImagePanel imgpanel = null;   
    Thread thr;
    String str1=new String();
    //from gesture
    int xcentre, ycentre,ij;
         static int iw = 320;
         static int ih = 240;
         static int  attenH = 400;
         static int attenW = 200;
         static int PIXCOUNTBB=5;
         static int IMIN=40;   //approximate location of hand
        static int IMAX=239;
        static int JMIN=5;
        static int JMAX=300;
         Image imgprocess;
         Image im;
         int xmin,xmax,ymin,ymax;
    int pix_fill[][]= new int [320][240];
    int pixel2[] = new int[76800];
    int pixel3[] = new int[76800];
    int pixel4[] = new int[76800];
    int pixel5[] = new int[76800];
    int pixel6[] = new int[attenH * attenW];
    double arr[][] = new double[21][2];
    int flag = 0;
    int ixmean = 0;
    int iymean = 0;
    //MyThread thread ;
    int threadflag = 1;
    public SwingCapture()   {
         setLayout(new BorderLayout());   
    //setSize(320,550);
    //setSize(320,550);      
    imgpanel = new ImagePanel();   
    capture = new JButton("Capture");   
    capture.addActionListener(this);       
    //String str1 = "vfw:Philips USB PC-Camera:0";   
    //String str2 = "vfw:Microsoft WDM Image Capture:2"; 
    //String str3 = "vfw:Video Blaster WebCam Go (VFW):0";  
      String str3 = "vfw:Video Blaster WebCam 3/WebCam Plus (VFW):1";  
    System.out.println("sur");
      String str2= "vfw:Microsoft WDM Image Capture (Win32):0";
    di =(CaptureDeviceInfo) CaptureDeviceManager.getDevice(str3);
    System.out.println("sur" + di);
    ml = di.getLocator();       
    try     {     
    player = Manager.createRealizedPlayer(ml);     
    player.start();     
    Component comp;           
    if ((comp = player.getVisualComponent()) != null)                   
          {add(comp,BorderLayout.NORTH);     
    add(capture,BorderLayout.CENTER);     
    add(imgpanel,BorderLayout.SOUTH);}   
    catch (Exception e)    
              e.printStackTrace();   
    thr = new Thread(this);
    public static void main(String[] args)   {   
    Frame f = new Frame("SwingCapture");   
    SwingCapture cf = new SwingCapture();       
    f.addWindowListener(new WindowAdapter() {      //overriding windowClosing
                                             public void windowClosing(WindowEvent e) {     
                                             playerclose();     
                                             System.exit(0); }       
    f.add("Center",cf);   
    f.pack();   
    f.setSize(new Dimension(320,550));   
    f.setVisible(true);
    /*for(int i=0;i<=10;i++)
         FrameGrabbingControl fgc = (FrameGrabbingControl)  player.getControl("javax.media.control.FrameGrabbingControl");     
    buf = fgc.grabFrame();           
    // Convert it to an image     
    btoi = new BufferToImage((VideoFormat)buf.getFormat());     
    img = btoi.createImage(buf);           
    // show the image     
    imgpanel.setImage(img);
    Gesture(img);
    imgprocess.flush();
    img.flush();
    try{
         Thread.sleep(10000);}
         catch(Exception e1){};
    public static void playerclose()   {   
    player.close();   
    player.deallocate(); 
    public synchronized void actionPerformed(ActionEvent e)   {   
    JComponent c = (JComponent) e.getSource();       
    if (c == capture)     {
         //thread started
         thr.start();
         while(ij<=7)
           if(threadflag ==1)
               try{
              System.out.println("Waiting");
                     wait();
                     System.out.println("Finished Waiting");
                catch(Exception e3)
                threadflag =0;
                System.out.println("Back");
                imgpanel.callPaint("<");
                threadflag=1;
                notify();
    public synchronized void run()
           ij = 0;
           while(ij<=7)
         if(threadflag ==1)
              //for( ij = 0; ij<=20;ij++)
    // Grab a frame   
    //this.imgpanel=imgpanel;
    System.out.println("ij : " + ij);
    FrameGrabbingControl fgc = (FrameGrabbingControl)  player.getControl("javax.media.control.FrameGrabbingControl");     
    System.out.println("After buf1 " + fgc);
    buf = fgc.grabFrame();
    System.out.println("After buf " + buf);
    // Convert it to an image     
    btoi = new BufferToImage((VideoFormat)buf.getFormat());     
    System.out.println("After btoi "+ btoi);
    img = btoi.createImage(buf);
    System.out.println("After img "+ img);
    //imgpanel.callpaint(">");
    // show the image     
    //System.out.println("rhododendron");
    //imgpanel.setImage(imgprocess);
    //System.out.println("cacatua");
    //pixel2=Gesture(img);
    Gesture(img);
    //imgpanel.repaint();
    //repaint();
    System.out.println("After Gesture");
    //String str = new String("C:\\test");
                   //str = str + ij + ".jpg";
    //System.out.println("After ");               
              //     SaveImage(str,imgprocess);
    //imgprocess=createImage(new MemoryImageSource(iw,ih,pixel2,0,iw));
    //repaint();
    /*try{
         Thread.sleep(10000);}
         catch(Exception e1){};*/
    //imgprocess.flush();
    //img.flush();
    ij++;
    System.out.println("ij: " + ij);
    threadflag = 0;
    notify();
    //System.out.println("After Notify");
    if(threadflag==0)
         try{
         wait();
    //     notify();
    //repaint();
         catch(Exception e2)
    //System.out.flush();
    /*flag =1;
         int cntleft=0;
         int cntright=0;
    for(int i=1;i<=7;i++)
        if(arr[i-1][0]<arr[0])
         cntright++;
    else
              cntleft++;
    if(cntleft>5)
         str1 = "Moving right";
         System.out.println("Moving right");
         imgpanel.callPaint(str1);
         else
    if(cntright>5)
         str1 = "Moving left";
              System.out.println("Moving left");
         imgpanel.callPaint(str1);
    else
         str1 = "No Movement";
              System.out.println("No Movement");
         imgpanel.callPaint(str1);
    /*class MyThread extends Thread
    MyThread()
         if(threadflag ==1)
              wait();
         else
              threadflag =0;
              imgpanel.callPaint();
              threadflag=1;
              notify();
    class ImagePanel extends Panel {   
    public Image myimg = null;
    String str2 = new String();
    public ImagePanel() {     
    setLayout(null);
    setSize(320,240);
    public void setImage(Image img) {     
    //System.out.println("cacatua");
    //this.myimg = img;
    //repaint();
    public void callPaint(String st)
         //this.str2 = st;
         System.out.println("in callPaint");
         System.out.println("xmean: "+ixmean);
         imgpanel.repaint();
         System.out.println("in out callPaint");
    public void paint(Graphics g) {     
    //if (myimg != null) {  
    //g.drawImage(imgprocess, 0, 0, null);
         System.out.println("xmean: "+ixmean);
         //System.out.println("in Paint of imgpanel");
    //g.drawImage(imgprocess,0,0,null);
    //if(flag==1)
    //g.drawString(str2, 20,20);
    //     else
              //repaint();
              g.drawString(">",ixmean,iymean);
              //repaint();
    //g.drawImage(imgprocess,0,0,null);
    //class Gesture //extends Applet
         /*int xcentre, ycentre;
         static int iw = 320;
         static int ih = 240;
         static int attenH = 400;
         static int attenW = 200;
         static int PIXCOUNTBB=5;
         static int IMIN=40; //approximate location of hand
    static int IMAX=239;
    static int JMIN=5;
    static int JMAX=300;
         Image imgprocess;
         Image im;
         int xmin,xmax,ymin,ymax;
    int pix_fill[][]= new int [320][240];
    int pixel2[] = new int[76800];
    int pixel3[] = new int[76800];
    int pixel4[] = new int[76800];
    int pixel5[] = new int[76800];
    int pixel6[] = new int[attenH * attenW];
         //public int intensity(int pix[][], int x, int y)*/
         public int intensity(int pix[][], int x, int y)
         int p, r, g, b, inten;
              //p=pix[x][y];
    p=pix[x][y];
              r = 0xff & p>>16 ;
              g = 0xff & p>>8;
              b = 0xff & p;
              //inten = (int)(0.33 * r + 0.56 g + 0.11b);
              inten = (int)(0 * r + 0 g + 0.11b);
              //inten = (int)( 0.11*b);
              return(int)(inten);
    public int min(int x, int y)
         if(x<y)
                   return(x);
              else
                   return(y);
         //public void init()
         public void Gesture(Image im)
              //int pixel3[] = new int[80000];
              //int pixel2[] = new int[76800];
         int whitepix=0;
              int coord[][] = new int[2][256];
              //int ymin, xmax,ymax,xmin;
              int no_elem_comp[] = new int[76800];
              int count = 0;
              float pskin[][] = new float[241][241];
              float pnoskin[][] = new float[241][241];
              int num = 0;
              String imname;
              //Image im;
              for(int i=0;i<2;i++)
                   for(int j=0;j<256;j++)
                   coord[i][j] = 0;
              //imname = getParameter("img");
              //im = getImage(getDocumentBase(),imname);
              int pixels[] = new int [iw * ih];
              int pix[][] = new int[iw][ih]; //changed iw and ih
              FileReader fr;
              BufferedReader br ;
              String s = new String();
              int l;
              int total;
              PixelGrabber pg = new PixelGrabber(im,0,0,iw,ih,pixels,0,iw);
              try
                   pg.grabPixels();
              catch(InterruptedException e) {}
              int size = iw * ih;
              for(int m=240; m<480;m++)
                   //System.out.println(m + " : " + pixels[m] );
                   int p = pixels[m];
                   int r = 0xff & (p>>16);
                   int g = 0xff & (p>>8);
                   int b = 0xff & (p);
                   //System.out.println("r : " + r + " g : " + g + " b : " + b);
              //imgprocess=createImage(new MemoryImageSource(iw,ih,pixels,0,iw));
              //repaint();
              ///////controller
              float C[][] = new float[16][size];
              for(int i=0;i<16;i++)
                   for ( int j=0;j<size;j++ )
                   C[i][j]=0;
              //System.out.println("End Controller");
    ////////fingerinit
              try{
              fr = new FileReader("skin");
              br = new BufferedReader(fr);
              //String s;
              s=br.readLine();
              l = Integer.parseInt(s);
              System.out.println("l : " + l);
              s=br.readLine();
              total = Integer.parseInt(s);
              System.out.println("total : " + total);
    String val = new String();
              for(int i=0; i<241; i++)
    for(int j=0; j<241; j++)
         s=br.readLine();
         int intval = Integer.parseInt(s);
              //pskin[i][j] = ((float)intval)/total;
         pskin[i][j] = (float)intval;
              fr.close();
              catch(Exception e)
              {System.out.println("Hello");
    try{
         fr = new FileReader("noskin");
         br = new BufferedReader(fr);
              s=br.readLine();
         l = Integer.parseInt(s);
              s=br.readLine();
         total = Integer.parseInt(s);
              for(int i=0; i<241; i++)
    for(int j=0; j<241; j++)
         s=br.readLine();
         int intval = Integer.parseInt(s);
              //pskin[i][j] = ((float)intval)/total;
         pnoskin[i][j] = (float)intval;
              fr.close();
              catch(Exception e)
                   System.out.println("Here:");
    System.out.println("after noskin");
              float A[][] = new float[size+1][20];
              try{
    System.out.println("in try");
              fr = new FileReader("svdnewdata");
              if(fr==null)
                   System.out.println("Could not open svdnewdata ");
                   System.exit(0);
              br = new BufferedReader(fr);
              for(int i1=0;i1<size;i1++)
                   s=br.readLine();
                   StringTokenizer st =new StringTokenizer(s,"\t");
                   //System.out.println("svd :" + s);
                   for(int j1=0;j1<20;j1++)
                             String val = st.nextToken();
                   //          System.out.println("val : " + val);
                             int intval=Integer.parseInt(val);
                             A[i1][j1]=intval;
              fr.close();
              catch(Exception e)
                   System.out.println("surbhi");
    System.out.println("after svdnewdata");
              ////////Process
              int points[][] = new int[2][size];
              int colors[][] = new int[3][size];
              int data[][] = new int[2][size];
              float prob[] = new float[size];
              ////////fingerpoint
              for(int i=0;i<size;i++)
                   int p = pixels[i];
                   int r=0xff & (p>>16);
                   int g=0xff & (p>>8);
                   int b=0xff & (p);
                   colors[0][i] = r;
    colors[1][i] = g;
                   colors[2][i] = b;
                   data[0][i] = (int)(i/iw)-1;
                   data[1][i] = (int)(i%iw)-1;
    float Cb_f = (float)(((-4818.0*r - 9527.0*g + 14345.0*b)/32768.0)+128.5);
                   float Cr_f = (float)(((14345.0*r - 12045.0*g - 2300.0*b)/32768.0)+128.5);
                   int Cb = (int)Cb_f;
                   int Cr = (int)Cr_f;
                                  //System.out.println("Cb :" + Cb);
                                  //System.out.println("Cr :" + Cr);
                   if(pnoskin[Cb][Cr] ==0)
    //System.out.println("sur :" );
                        prob[i]=1;
                   else
                        prob[i]=pskin[Cb][Cr]/pnoskin[Cb][Cr];
              //System.out.println("anui");
    for(int a=0;a<size ;a++)
         if( prob[a]>0.05)
         //     { System.out.println("Ishsani"); 
              pixel2[a]=0xff000000 | 0x000000ff;//}
         else
         //     {System.out.println("Ishsani11");
              pixel2[a]=0xff000000 | 0x00ff0000;
                   int k=0;
                   int buffer[] = new int[3];
                   //int pix[][] = new int[ih][iw];
                   for(int i=0;i<ih;i++)
                        for(int j=0;j<iw;j++)
                        pix[j][i]= pixel2[k++];
    //System.out.println("out k:" + k);
                   for(int i=1;i<ih-1;i++)
                   for(int j=1;j<iw-1;j++)
                        whitepix = 0;
                        for(int i1=i-1;i1<=i+1;i1++)
                             for(int j1=j-1;j1<j+1;j1++)
                        buffer[0]= 0x000000ff & (pix[j1][i1]>>16);
                        buffer[1]= 0x000000ff & (pix[j1][i1]>>8);
                             buffer[2]= 0x000000ff & (pix[j1][i1]);
                             //if(((buffer[0]==-1)&&(buffer[1]==-1))||((buffer[2]==-1)&&(buffer[1]==-1))||((buffer[0]==-1)&&(buffer[2]==-1)))
                             if(buffer[2]==255)
                                  whitepix++;
                        if(whitepix>=3)
                             //pix[j][i] = (255<<24) | (255 << 16) | (255<<8) | (255);
                             pix[j][i] = 0xff000000 | 0x000000ff;
              //               System.out.println("if : " + pix[j][i]);
                        else
                             //pix[j][i] = 0xff|(0<<16)|(0<<8)|0;
                             pix[j][i] = 0xff000000 | 0x00ff0000;
              //               System.out.println("else : " + pix[j][i]);
                   }//end for
         int b=0;
                   for(int i=0;i<ih;i++)
                   for(int j=0;j<iw;j++)
                        pixel2[b++] = pix[j][i];
    //imgprocess=createImage(new MemoryImageSource(iw,ih,pixel3,0,iw));
    //repaint();
              IdenOutline(pix);
              IdenOutline(pix_fill);
              IdenOutline(pix_fill);
              IdenOutline(pix_fill);
              IdenOutline(pix_fill);
              IdenOutline(pix_fill);
              //IdenOutline(pix_fill);
    calcBoundary();
              System.out.println("xmax : " + xmax + " xmin : " + xmin);
    System.out.println("ymax : " + ymax + " ymin : " + ymin);
              BBox();
              CalcMvt();
              b=0;
                   for(int i=0;i<ih;i++)
                   for(int j=0;j<iw;j++)
                        pixel2[b++] = pix_fill[j][i];
    //imgpanel.callPaint(">");
    //imgpanel.repaint();
    // imgprocess.flush();
    //imgprocess=createImage(new MemoryImageSource(iw,ih,pixel2,0,iw));
    //repaint();
    //thread.start();
    //try{
    //wait();
    //catch(Exception e)
    //imgpanel.callPaint(">");
    //repaint();
    //imgprocess.flush();
    /*          public void run()
                   imgpanel.callPaint(">");
                   notify();
    /*public void paint(Graphics g)
         g.drawString(str1, 310,300);
         System.out.println("Came in paint");
    //g.drawString("Coordinates of the Centroid is "+ xcentre + " , " + ycentre , 10,40);
    //g.drawImage(imgprocess,0,0,null);
         //System.out.println("Came in paint out");
    //g.drawImage(im,0,0,this);
    //if(imgprocess==null){
              System.out.println("ishani1");
              //imgprocess=createImage(new MemoryImageSource(iw,ih,pixel2,0,iw));
              //repaint();
         System.out.println("ishani2");
    //g.drawImage(imgprocess,0,0,null);
    //g.drawImage(imgprocess,0,400,null);
    System.out.println("ishani3");
    //repaint();
    void BBox()
    for(int i=xmin ; i<=xmax;i++)
         pix_fill[i][ymax] = 0xff0000ff;
         pix_fill[i][ymin] = 0xff0000ff;
         System.out.println("Came here");
         for(int j=ymin;j<=ymax;j++)
              pix_fill[xmax][j] = 0xff0000ff;
    pix_fill[xmin][j] = 0xff0000ff;
         System.out.println("Came here2");
    void calcBoundary()
    int minrow,maxrow,mincol,maxcol,flag=0;
         minrow=maxrow=mincol=maxcol=0;
         for(int i=0;i<ih;i++)
         for(int j=0;j<iw;j++)
         if(pix_fill[j][i] == 0xff0000ff)
              flag = 1;
              minrow = i;
              break;
         if(flag==1)
         break;
         flag=0;
    for(int i=(ih-1);i>=0;i--)
         for(int j=0;j<iw;j++)
              if(pix_fill[j][i] == 0xff0000ff)
                   flag =1;
                   maxrow=i;
                   break;
              if(flag==1)
              break;
         flag =0;
    for(int j=0;j<iw;j++)
         for(int i=0;i<ih;i++)
              if(pix_fill[j][i] == 0xff0000ff)
                   flag=1;
                   mincol = j;
                   //System.out.println("row : " + i + " Col : " + mincol);
                   break;
              if(flag==1)
                   break;
         flag =0;
    for(int j=(iw-1);j>=0;j--)
         for(int i=0;i<ih;i++)
              if(pix_fill[j][i] == 0xff0000ff)
                   flag =1;
                   maxcol = j;
                   System.out.println("row : " + i + " Col : " + maxcol);
                   break;
              if(flag==1)
    break;
    xmax = maxcol;
    xmin = mincol;
    ymax = maxrow;
    ymin = minrow;
    return;
    void IdenOutline(int pix_temp[][])
         int n,k,l,i,j;
         for(i=0;i<ih;i++)
              for(j=0;j<iw;j++)
         if(pix_temp[j][i]==0xffff0000)
                        continue;
                   else
                        for(k=1;(j+k)<320;k++)
                        if(pix_temp[j+k][i]!=0xffff0000)
                        continue;
                        else
                             break;
                             for(l=1;(i-l)>0;l++)
                        if(pix_temp[j][i-l]!=0xffff0000)
                                  continue;
                             else
                                            break;
                                       /*for(m=1;j-m>0;m++)
                                            if(pix_fill[j-m][i])!=0xff0000ff)
                                            continue;
                                       else*/
                                                 for(n=1;(i+n)<240;n++)
                        if(pix_temp[j][i+n]!=0xffff0000)
                                                 continue;
                                                 else
    break;
                                                      if((k<15)&&(n<20)&&(l<20))
                                                           pix_temp[j][i]=0xffff0000;
                                                      else
                                                                     if((k<15)&&(l<10)&&(n>10))
    pix_temp[j][i]=0xff0000ff;
                                                                else
                                                                          if((n<10)&&(k<15)&&(l>10))
                                                                          pix_temp[j][i]=0xff0000ff;
                                                                     else
                                                                          if((n<10)&&(l<10)&&(k>15))
                                                                          pix_temp[j][i]=0xff0000ff;
    int b1=0;
                        for(int a=0;a<ih;a++)
                        for(int d=0;d<iw;d++)
                        pixel2[b1++] = pix_temp[d][a];
                        pix_fill[d][a] = pix_temp[d][a];
    //imgprocess=createImage(new MemoryImageSource(iw,ih,pixel4,0,iw));
              //repaint();
    public void SaveImage(String s,Image im)
         System.out.println("i m here" + im);
         /* try{
              Thread.sleep(1000);
         catch(Exception e)
         //BufferedImage bi = new BufferedImage(im.getWidth(null, im.getHeight(null), BufferedImage.TYPE_INT_RGB);
    BufferedImage bi = new BufferedImage(320, 240, BufferedImage.TYPE_INT_RGB);
         System.out.println("i m here" + bi);
         Graphics2D g2 = bi.createGraphics();
         g2.drawImage(im, null, null);
         System.out.println("i m here" + g2);
         FileOutputStream out = null;
         try {      
              out = new FileOutputStream(s);
         catch (java.io.FileNotFoundException io)
              System.out.println("File Not Found");
    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
         JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bi);
         param.setQuality(0.5f,false);
         encoder.setJPEGEncodeParam(param);
         try
              encoder.encode(bi);
              out.close();
         catch (java.io.IOException io)
              System.out.println("IOException");
         public void CalcMvt()
              double xmean=(xmax+xmin)/2;
              double ymean=(ymax+ymin)/2;
              ixmean = (int) xmean;
              iymean = (int)ymean;
              arr[ij][0]= xmean;
              arr[ij][1]=ymean;
         }//end of class
    /*public class SCapture
    public static void main(String[] args) {   
    Frame f = new Frame("SwingCapture");
    SwingCapture cf = new SwingCapture();
    f.addWindowListener(new WindowAdapter() {      //overriding windowClosing
    public void windowClosing(WindowEvent e) {     
    playerclose();
    System.exit(0); }
    f.add("Center",cf);
    f.pack();
    f.setSize(new Dimension(320,550));
    f.setVisible(true);*/
    /*for(int i=0;i<=10;i++)
         FrameGrabbingControl fgc = (FrameGrabbingControl) player.getControl("javax.media.control.FrameGrabbingControl");
    buf = fgc.grabFrame();
    // Convert it to an image
    btoi = new BufferToImage((VideoFormat)buf.getFormat());
    img = btoi.createImage(buf);
    // show the image
    imgpanel.setImage(img);
    Gesture(img);
    imgprocess.flush();
    img.flush();
    try{
         Thread.sleep(10000);}
         catch(Exception e1){};

    Not sure exactly what you mean...
    Here, try this sample, use your ImagePanel with a standard frame. Just add the panel to the frame, make the frame visible, shrink and restore it a few time, see if your paint method gets called...
    If it works correctly, good, you know the ImagePanel is fine, and yout problem is with your other class. If it doesn't work, then concentrate on your ImagePanel and explain exactly HOW it doesn't work... (like any errors, what gets shown/printed to the command line, exactly how it misbehaves...
    public void ImagePanelTest extends Frame {
      public ImagePanelTest (String title) {
        super(title);
      public void main(String[] args) {
        ImagePanel ip = new ImagePanel();
        ImagePanelTest ipt = new ImagePanelTest("ImagePanel Test");
          ipt.add(ip);
          ipt.setSize(new Dimension(300,300));
          ipt.addWindowListener(new WindowAdapter() {
            public void windowClosing(windowEvent we) {
              dispose();
              System.exit(0);
          ipt.show();
      }

  • Generate prov.xml for Creative Cloud. Return Code 27

    We're trying to follow this guide (Creative Cloud Help | Using Adobe Provisioning Toolkit Enterprise Edition) to serialize a package (or something). We're stuck on generating prov.xml. My best attempt at an entry is:
    C:\Program Files (x86)\Common Files\Adobe\OOBE\PDApp\CCP\utilities\APTEE>adobe_prtk.exe --tool=VolumeSerialize --generate --serial=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx --regsuppress=ss --eulasuppress --locales=en_US --provfilepath=C:\Program Fil
    es (x86)\Common Files\Adobe\OOBE\PDApp\CCP
    It says half of this is optional, but I'm skeptical.
    Anyway, I'm getting return code 27. This indicates that it is unable to edit the prov.xml file specified. I didn't specify a prov.xml file, I'm trying to make one. The syntax I'm using differs from what I found on the page I linked, as that was giving me syntax errors. I lifted this off someone else's code. I've tried just about every variation I can think of. Any help would be appreciated.
    This is on Windows

    One of these links may help
    http://helpx.adobe.com/creative-cloud/packager.html
    http://forums.adobe.com/community/download_install_setup/creative_suite_enterprise_deploym ent

  • Code returns "null" and "0"s in main module - why?

    I am coding a program that is in two modules. The main module serves it's standard function. The inventory class/module has three functions - 1) request stock input on 4 data points (1 String and 3 integers, one of which is a double) - 2) calculate the value of the inventory, and - 3) return string which reads out the 4 data points and the calculation showing the total value of the inventory. I've created the 3 functions in the inventory class/module, but obviously don't have them referring to each other correctly because when we come to the end of the program the output is null for the String and "0"s for the int/doubles. The code is below - any ideas about how to overcome the empty output? The code compiles fine and acts like it is going to work, but when it comes to the final command line it outputs
    "null, which is item number 0, has 0 currently in stock at a price of 0.00 each. The total value of inventory in stock is 0.00"
    Main module:
    public class Main {
        @SuppressWarnings("static-access")
        public static void main(String[] args) {
            Inventory inventory = new Inventory(); //call Inventory class
            inventory.inventoryInput();
            Inventory results = new Inventory();
            results.inventoryResults(); //call for inventoryResults in Inventory class
    }Inventory module:
    import java.util.Scanner;
    import static java.lang.System.out;
    public class Inventory
      //declare and initialize variables
       int itemNumber = 0;
       String productName;
       int stockAmount = 0;
       double productCost = 0;
       double totalValue = 0;
       String inventoryResults;
       //initialize scanner
       Scanner input = new Scanner(System.in);
       public void inventoryInput ()
       out.println("Please enter item number: "); //prompt for item number
          itemNumber = input.nextInt();
       out.println( "Enter product name/description: "); //prompt for product name
          productName = input.next();
       out.println("Quantity in stock: ");
          stockAmount = input.nextInt(); // prompt for stock quantity
       out.println("What is the product cost for each unit? ");
          productCost = input.nextDouble(); // prompt for product cost
        } // end inventoryInput
        public double totalValue( double stockAmount, double productCost )
          totalValue = stockAmount * productCost;
          return totalValue; // return stock value
        } // end totalValue
        public void inventoryResults()
        out.printf("%s, which is item number %d, has %d currently in stock at a " +
         "price of %.2f each. The total value of inventory in stock is " +
         "%.2f\n.", productName, itemNumber, stockAmount, productCost, totalValue);
        } // end inventoryResult
    }// end method

    justStartingOut wrote:
    Actually my final solution was quite simple - I moved the calculation and final formated print text statements into the body of Inventory's class code. It now works. "Works" scares me a bit.
    Someone cooking dinner might rummage about in the fridge and the cupboards to see what's there. Do imaginative things with what they come up with. And, with a bit of luck come up with something tasty or, at any rate edible.
    A physician deciding on a medical treatment would do well to try a more cautious approach. A specific aim would be a good thing. And a calculated appreciation of the documented effects of each medicine. And how they interact.
    It's up to you to determine which approach your coding should resemble. But it seems to me that your original Main class had a perfectly good reason to exist. It was a driver class whose purpose seemed to be to create and use an Inventory. (And using an Inventory is a very different thing from being an Inventory, so it made perfect sense to have two different classes.) To me it works or not, depending on whether it fufills that purpose. And what you have done is not so much solve the problem of it not working, as avoid that problem.
    (If by "moved" you mean that the outputting now occurs as part of - or is called from - inventoryInput() then that is not a good thing. The input method should input: just input.)
    I think that is because once the original input was loaded into the program (when I entered product number, name, price and value), the entries were dropped when the code switched to the next step. I think your intuition is entirely correct. In particular look at what your original main() method does (my comments replacing yours):
    Inventory inventory = new Inventory(); // (A) Create an inventory...
    inventory.inventoryInput(); // ... and put stuff into it
        // (B) Create some new entirely different (and empty) inventory...
    Inventory results = new Inventory();
    results.inventoryResults(); // ... and print its contentsInstead of creating a second inventory, try printing the results of the first one.
    Edited by: pbrockway2 on Apr 22, 2008 12:37 PM
    Whoops ... just read reply 2.
    It might sense, though to call totalValue() at the end your input method (because at that point the total value has changed). Or do away with that method - which you worked on getting right in your other thread ;)

  • Sample source code for fields mapping in expert routine

    Hi All
    Iam writing the expert routine from dso to cube for example I have two fields in dso FLD1,FLD2
    same fields in infocube also ,can any body provide me sample abap code to map source fields to target fields in expert routine,your help will be heighly appreciatble,it's an argent.
    regards
    eliaz

    Basic would be ;
    RESULT_FIELDS -xxx = <SOURCE_FIELDS> -xxx
    you have the source fields as source, and result fields for as the target. In between you can check some conditions as in other routines of transformation.
    BEGIN OF tys_SC_1, shows your source fields ( in your case DSO chars and key figures)
    BEGIN OF tys_TG_1, , shows your result fields ( in your case Cube characteristics)
    Hope this helps
    Derya

  • TS2446 My phone want let me download apps I put the password in then it's say billing options which tell me I have invalid security code

    My phone want let me download any apps when I put the password in it take me to billing option which tell me I have the wrong security code and that's the security code that was on the card on the account

    iTunes Store: My credit card's security code or zip code does not match my bank's records
    http://support.apple.com/kb/TS1646

  • Cannot delete file from external hard drive (error code 36) in Finder, but Terminal is ok

    I have a relatively new Macbook Pro Retina 15" and have a Western Digital 1 TB Passport.  I've been using the passport for about a year now without any problems on older Macbooks in my house.  I used to be able to read and write to this drive no problem.  I am using the Paragon NTFS for Mac software in order to read and write to the NTFS drive.  When I navigate through the drive in Finder, if I try to create a new folder, I do not have a problem.  If I try to delete that folder I just created, I get this error:
    The Finder can’t complete the operation because some data in “untitled folder” can’t be read or written.
    (Error code -36)
    The folder has nothing in it whatsoever.  I just created it.  But if I go to Terminal and I run
    rm -rf "untitled folder"
    This works fine.  Why is Terminal acting different than Finder?  This does not happen on my other Macbooks.  Thanks in advance.

    Thanx for such qucik reply!!! The pages were great, it had an answer for my problem, but unfortunately it also involved me dealing with it only on the MacIntosh HD itself, not on mounted external drive I suppose... So it didn't work they say that there is an icon in the left corner indicating locked folder - I don't see any icon on it. It says you can untick the box to unlock the folder - there is no tick to be unticked. Finally, they say that if I don't have permition or rights I cannot delete it. But how do i change permittion which already says that i can read and write in it? So everything appears to be normal only I cannot delete it. there is not even any warnig telling me I don't have enough rights, it just requires the password and after me typing it in it makes the sound of scraping paper but does nothing more. I aslo had some problems with emptying Trash after being seemingly succesful with one file and had got so far to have them appear in the Trash (no clue how this one actully got there though..) I followd the advice and emptied the Trash with Terminal. The Folder is still there but it shows 0 Kb... So far so good BUT: It is still on the external drive, so I obviously only managed to copy it into the Trash!!! Phew, innit a bit too tight to poor owners, this macbook?? I want my rights back!

  • Report generation failed----​error code:-1720​5; Access Denied.

    Hi, All
        i have a trouble about report generation.it seems the error happened at the "write UUT report"--this step is teststand report generation'DLL.
        detail:
        An error occurred calling 'Save' in 'Report' of 'NI TestStand 2010 SP1 API'
    Access Denied.. Error writing to file 'D:\program\seq\xxx.xml'.
    The file might be open in another application. If file access is intermittently denied, you should try disabling the Microsoft FindFast utility. 
        error code:-17205; Access Denied.
        locationtep 'Write UUT Report' of sequence 'Single Pass' in 'SequentialModel.Seq'
        How to fix it?
        Thanks a lot.
    BR

    Hm, it looks like the file might be open in another application. If you see that file accesss is intermittently denied, you should try disabling the Microsoft FindFast utility.
    CTA, CLA, MTFBWY

  • Error in Printing Crystal Report Directly to Printer using SDK Code

    Hello ,
    I am trying to print a crystal report created in SAP Crystal Reports 2008 through SDk Code using one parameter
    as (Document Number).But While running the Code the Report is not getting printed and also the system is
    not able to fetch the correct data in the report using the supplied parameter .
    I am using Visual Studio 2005 Crystal Report dll s in my code :-
    Imports CrystalDecisions.CrystalReports.Engine
    Imports CrystalDecisions.Shared
    Imports CrystalDecisions.CrystalReports
    Imports System
    Imports System.Data.SqlClient
    Imports System.IO
    For Clarification i am pasting my code below :-
                Dim oRpt As ReportDocument
                oRpt = New ReportDocument
                oRpt.Load(Path)
                With crConnectionInfo
                    .ServerName = Server
                    .DatabaseName = Database
                    .UserID = User
                    .Password = Password
                End With
                CrTables = oRpt.Database.Tables
                For Each CrTable In CrTables
                    crtableLogoninfo = CrTable.LogOnInfo
                    crtableLogoninfo.ConnectionInfo = crConnectionInfo
                    CrTable.ApplyLogOnInfo(crtableLogoninfo)
                Next
                oRpt.ParameterFields("Document Number").CurrentValues.AddValue(Parameter)
                If Printer <> "" Then
                    oRpt.PrintOptions.PrinterName = Printer
                End If
                oRpt.PrintToPrinter(Copies, False, 0, 1)
            Catch ex As Exception
                SBO_Application.MessageBox(ex.Message)
            End Try
    Please suggest me what i have to do in my code to print the report with correct data in report.
    Thanks & Regards,
    Amit

    k

  • Closing stock T code reqd

    hi all,
    i want to take the report for the closing stock of plant/sloc on a particular date,but am not able to find out the t code,have tried with MB5B,still am not getting the report.
    ur help required in this
    thanks and regards
    Vijay

    Hi,
    As somebody pointed out the right T code is MC.9, which would give you the stock value for all the materials in a plant.However , fr Quantities you may have to add the field required in the choose Key figures icon and refine your report further.
    Thanks in Advance,
    Nagrajan

Maybe you are looking for

  • Printing requirements for Bi publisher report

    Hi all Can any one tell me the steps required for me to look at the setups on my server side so that i can print the reports using the bursting API.The problem is i am not able to debug the log file as there is no connection error or any other except

  • Adobe Flash Player Will Not Work with Safari Mac OS 10.9.2

    I have tried numerous times to install Adobe Flash Player for Mac OS 10.9 and get Plug-in error when I try to run it.  Before the suggested update, Flash Player ran fine.  I would not have tried the update except the files on the web site that I am u

  • Macbook a1181 airport antenna cable socket problem

    Was replacing cracked screen on Macbook A1181 and in the process (quite unfortunately), both black and white antenna cables for the airport card were yanked from (ripped out of) their metal sockets.  Tried to delicately feed the cables back into thei

  • Boot camp error

    Tried to install windows using boot camp got to the screen where it asks to set the partition size, which i set to 100GB after 3 min i get a message saying "the disk cannot be partitioned because some files can't be moved" and HD needs to be formatte

  • How to use a timer in director to count down to quit

    how to use a timer in director to count down to quit