ByteArray.uncompress() Error

I'm attempting to compress a string on the server and uncompress it in Flex.  I'm getting a generic error when calling uncompress() and I assume it is because I'm encoding the string incorrectly.  I'm using C# on the server, and Flex 2 on the client (so only zlib compression).
Does anyone have a code example on the server of this working?

Hi Brent,
Yes, for unzipping, we really have to split the zip files, as uncompress doesn't work for larger zip files(it crashes on device).
Since my file size would range from 200-400MB, for now, I'm planning to load the raw file directly(running out of time to deliver it :| ). This too was failing, when i tried to readByes\writeBytes, after loading the file completely(since it runs out of memory). But I came across a solution right here:
http://stackoverflow.com/questions/14583247/air-as3-download-large-file-trough-ipad-applic ation
It basically writes data to the disk, as and when data gets downloaded in chunks. I felt it was a great idea! Apparantly, there won't be any memory issues too with that approach
And yes, as you have mentioned future plan would be to load and unzip zip files.
Thanks Brent, that helped too

Similar Messages

  • AS API(ByteArray.uncompress) doesn't work as expected in flash player 15.0.0.189 .

    This API is work well in flash player 15.0.0.167 and other previous player version.
    In the flash player 15.0.0.189 debug version, it will alert Error message:
    RangeError: Error #1506: 指定的范围无效。
      at flash.utils::ByteArray/_uncompress()
      at flash.utils::ByteArray/uncompress()
      at ?/bytesLen()
      at ?/init()
      at flash.display::DisplayObjectContainer/addChildAt()
      at PreLoader/onComplete()
    The same situation also occurred in ActiveX version, plugin version and Chrome PPAPI version.

    It's possible that this is the result of a security change.
    Please file a bug at http://bugbase.adobe.com/.  Include a SWF that demonstrates the example so that we can debug it.
    If you post the bug number here, I will get a notification and will ensure that it gets routed to the right engineer.
    Thanks!

  • Bytearray uncompress filestream wirtebytes error

    Hi,
    I'm developing an app for iPad in which I'm trying to load a zip file from a remote url, save that zip file on device and then trying to unzip it.
    It works fine both on laptop(while testing as AIR app) and also on the device(iPad) if zip file size is around 20 - 25MB, with it's internal file being around 140 - 170MB. But if the zip file size is larger (beyond 50MB) then it crashes while uncompressing the zip file on the device. It still works fine on laptop though.
    I'm compiling the code with Flex 4.6 overlayed on AIR 3.6
    iPad iOS version is 6.0.1
    Using following code :
    private function unzipFile():void
                progress = progress + fileName +' unzipFile started\n';
                saveLog();
                var zStream:FileStream = new FileStream();
                var bytes:ByteArray = new ByteArray();
                var fileName:String = new String();
                var flNameLength:uint;
                var xfldLength:uint;
                var offset:uint;
                var compSize:uint;
                var uncompSize:uint;
                var compMethod:int;
                var signature:int;
                progress = progress + fileName +'before zStream.open\n';
                saveLog();
                zStream.open(fileLocal, FileMode.READ);
                progress = progress + fileName +'after zStream.open\n';
                saveLog();
                bytes.endian = Endian.LITTLE_ENDIAN; 
                while (zStream.position < fileLocal.size)
                {  progress = progress + fileName +'before zStream.readBytesbytes, 0, 30\n';
                    saveLog();
                    zStream.readBytes(bytes, 0, 30);
                    progress = progress + fileName +'after zStream.readBytesbytes, 0, 30\n';
                    saveLog();
                    bytes.position = 0;
                    signature = bytes.readInt();
                    if (signature != 0x04034b50)
                        break;
                    bytes.position = 8;
                    compMethod = bytes.readByte();
                    offset = 0;
                    bytes.position = 26;
                    flNameLength = bytes.readShort();   
                    offset += flNameLength;    
                    bytes.position = 28;    
                    xfldLength = bytes.readShort();
                    offset += xfldLength;   
                    zStream.readBytes(bytes, 30, offset);
                    bytes.position = 30;
                    fileName = bytes.readUTFBytes(flNameLength); 
                    bytes.position = 18;
                    compSize = bytes.readUnsignedInt(); 
                    bytes.position = 22;  
                    uncompSize = bytes.readUnsignedInt();
                    progress = progress + fileName +'before zStream.readBytes(bytes, 0, compSize)\n';
                    saveLog();
                    zStream.readBytes(bytes, 0, compSize);
                    progress = progress + fileName +'after zStream.readBytes(bytes, 0, compSize)\n';
                    saveLog();
                    if (compMethod == 8)
                        try
                            progress = progress + fileName +' before bytes.uncompress\n';
                            saveLog();
                            bytes.uncompress(CompressionAlgorithm.DEFLATE);
                            //bytes.uncompress(CompressionAlgorithm.LZMA);
                            progress = progress + fileName +' after bytes.uncompress\n';
                            saveLog();
                            //outFile(fileName, bytes); 
                        catch(error:Error)
                            progress = progress + fileName +' bytes.uncompress catch\n';
                            saveLog();
                  //write bytes to a file locally here
    It fails on this line:
    bytes.uncompress(CompressionAlgorithm.DEFLATE);
    and gets inside catch block.
    To avoid this problem, I also tried to load the file which was there in the zip file, directly using remote url(file size and download time will be more), but in this case, after loading the file, reading the bytearray data of it, when I try to write this bytearray to a filestream, it crashes again!
    Just wanted to know if there is any file size limit on mobile\iOS devices, while unzipping a file and while writing bytearray data to a filesystem or am I doing something wrong here?
    Kindly help, as I'm stuck with this and cannot really proceed on this project using Flex AIR if this doesn't work.
    -Deepak

    Hi Brent,
    Yes, for unzipping, we really have to split the zip files, as uncompress doesn't work for larger zip files(it crashes on device).
    Since my file size would range from 200-400MB, for now, I'm planning to load the raw file directly(running out of time to deliver it :| ). This too was failing, when i tried to readByes\writeBytes, after loading the file completely(since it runs out of memory). But I came across a solution right here:
    http://stackoverflow.com/questions/14583247/air-as3-download-large-file-trough-ipad-applic ation
    It basically writes data to the disk, as and when data gets downloaded in chunks. I felt it was a great idea! Apparantly, there won't be any memory issues too with that approach
    And yes, as you have mentioned future plan would be to load and unzip zip files.
    Thanks Brent, that helped too

  • ByteArray.uncompress() problem

    Hello
    Does the uncompress method of ByteArray only supports level 3
    compressed streams? Because I have a valid zlib compressed file but
    compressed in level 2, and Flash always throws me the 2058 error
    message.
    I've also tried using the DefaultCompressionAlgorithm class
    for AIR with its two compression methods, but with no success.
    Doing some quick tests with python using the same file gets
    uncompressed with no problems.

    I am having problems with uncompress as well. See my
    code.

  • Error 2032 in communication between Flex Client and WCF

    Hi All,
    I'm trying to establish communication between Flex Client
    and WCF service.
    WCF service accepts gZip compressed data and returns gZip
    compressed results.
    So I used Flex ByteArray.compress() and
    ByteArray.uncompress() for this purpose. However, it throws error
    2032.
    The gZip compression/decompression uses MemoryStream class in
    C#. Based on my previous experience, memory stream communication
    between Flex and C# gives erro 2032.
    Is there a work around for this?
    Thanks,
    Vishal

    I read some thread in the forum, and found somebody had the similar problem with me. Just want to know how to settle this problem.
    In the client/server program. Client is a JAVA program and Server a
    VC++ program. The connection works, and the problem appears after some time. The Client sends a lots of requests to Serverm, the server seems receive nothing. But at the same time, the server is able to send messages to Client. The Client also can get the messages and handle them. Don't understand why there this problem and why it appears when it wants.
    The client is a Win2k platorm with JDK1.3.1 and the server is also a Win2K platform with VC++ 6.0.
    In the Client, using:
    inputFromServer = new BufferedReader(new InputStreamReader(socket.getInputStream()));
    outputToServer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())),true);
    Hope can get your help.

  • Variable ByteArray is not defined in generated introspection file

    I am getting this error, Variable ByteArray is not defined.   This worked fine against Flex SDK 4.0 and is now throwing a runtime  error once it is built against the 4.5 SDK.  Is this related to updates  to the introspection in Flash Builder?
    Keith H.
    ReferenceError: Error #1065: Variable ByteArray is not defined.
    at global/flash.utils::getDefinitionByName()
    at  com.adobe.serializers.utility::TypeUtility$/assignProperty()[C:\depot  \flex\ide_trunk\ide_builder\com.adobe.flexbuilder.dcrad\serializers\sr  c\com\adobe\serializers\utility\TypeUtility.as:593]
    at  com.adobe.serializers.utility::TypeUtility$/convertToStrongType()[C:\  depot\flex\ide_trunk\ide_builder\com.adobe.flexbuilder.dcrad\serialize  rs\src\com\adobe\serializers\utility\TypeUtility.as:562]
    at  com.adobe.serializers.utility::TypeUtility$/convertListToStrongType()  [C:\depot\flex\ide_trunk\ide_builder\com.adobe.flexbuilder.dcrad\seria  lizers\src\com\adobe\serializers\utility\TypeUtility.as:518]
    at  com.adobe.serializers.utility::TypeUtility$/assignProperty()[C:\depot  \flex\ide_trunk\ide_builder\com.adobe.flexbuilder.dcrad\serializers\sr  c\com\adobe\serializers\utility\TypeUtility.as:623]
    at  com.adobe.serializers.utility::TypeUtility$/convertToStrongType()[C:\  depot\flex\ide_trunk\ide_builder\com.adobe.flexbuilder.dcrad\serialize  rs\src\com\adobe\serializers\utility\TypeUtility.as:562]
    at  com.adobe.serializers.utility::TypeUtility$/convertListToStrongType()  [C:\depot\flex\ide_trunk\ide_builder\com.adobe.flexbuilder.dcrad\seria  lizers\src\com\adobe\serializers\utility\TypeUtility.as:518]
    at  com.adobe.serializers.utility::TypeUtility$/assignProperty()[C:\depot  \flex\ide_trunk\ide_builder\com.adobe.flexbuilder.dcrad\serializers\sr  c\com\adobe\serializers\utility\TypeUtility.as:623]
    at  com.adobe.serializers.utility::TypeUtility$/convertToStrongType()[C:\  depot\flex\ide_trunk\ide_builder\com.adobe.flexbuilder.dcrad\serialize  rs\src\com\adobe\serializers\utility\TypeUtility.as:562]
    at  com.adobe.serializers.utility::TypeUtility$/convertResultHandler()[C:  \depot\flex\ide_trunk\ide_builder\com.adobe.flexbuilder.dcrad\serializ  ers\src\com\adobe\serializers\utility\TypeUtility.as:436]
    at mx.rpc.soap::Operation/http://www.adobe.com/2006/flex/mx/internal::processResult()[E:\dev\hero_private\frameworks\projects\rpc\src\mx\rpc\soap\Operati on.as:953]
    at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[E:\dev\hero_private\frameworks\projects\rpc\src\mx\rpc\AbstractInvo ker.as:313]
    at mx.rpc::Responder/result()[E:\dev\hero_private\frameworks\projects\rp c\src\mx\rpc\Responder.as:56]
    at mx.rpc::AsyncRequest/acknowledge()[E:\dev\hero_private\frameworks\pro jects\rpc\src\mx\rpc\AsyncRequest.as:84]
    at  DirectHTTPMessageResponder/completeHandler()[E:\dev\hero_private\fram  eworks\projects\rpc\src\mx\messaging\channels\DirectHTTPChannel.as:451 ]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/onComplete()

    I am facing similar error. Please let me know the links where you find solution for this problem.
    I have many files generated upon introspection of a web service which contains similar line as follows:
    model_internal::propertyTypeMap["uid"] = "ByteArray";
    ReferenceError: Error #1065: Variable ByteArray is not defined.
        at global/flash.utils::getDefinitionByName()
        at com.adobe.serializers.utility::TypeUtility$/assignProperty()[C:\depot\flex\ide_trunk\ide_ builder\com.adobe.flexbuilder.dcrad\serializers\src\com\adobe\serializers\utility\TypeUtil ity.as:593]
        at com.adobe.serializers.utility::TypeUtility$/convertToStrongType()[C:\depot\flex\ide_trunk \ide_builder\com.adobe.flexbuilder.dcrad\serializers\src\com\adobe\serializers\utility\Typ eUtility.as:562]
        at com.adobe.serializers.utility::TypeUtility$/convertResultHandler()[C:\depot\flex\ide_trun k\ide_builder\com.adobe.flexbuilder.dcrad\serializers\src\com\adobe\serializers\utility\Ty peUtility.as:436]
        at mx.rpc.soap::Operation/http://www.adobe.com/2006/flex/mx/internal::processResult()[E:\dev\hero_private\frameworks \projects\rpc\src\mx\rpc\soap\Operation.as:953]
        at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[E:\dev\hero_private\frameworks \projects\rpc\src\mx\rpc\AbstractInvoker.as:313]
        at mx.rpc::Responder/result()[E:\dev\hero_private\frameworks\projects\rpc\src\mx\rpc\Respond er.as:56]
        at mx.rpc::AsyncRequest/acknowledge()[E:\dev\hero_private\frameworks\projects\rpc\src\mx\rpc \AsyncRequest.as:84]
        at DirectHTTPMessageResponder/completeHandler()[E:\dev\hero_private\frameworks\projects\rpc\ src\mx\messaging\channels\DirectHTTPChannel.as:451]
        at flash.events::EventDispatcher/dispatchEventFunction()
        at flash.events::EventDispatcher/dispatchEvent()
        at flash.net::URLLoader/onComplete()
    Thanks,
    Deepa

  • No compilation error but have problems when running.

    Hello all,
    After implementing the examples given from the TextComponentJavaDemo in Java Tutorials I tried to get the fonts to change text in the JEditorPane but to no avail.
    The problem I am having now is some java.lang.Null.PointerException .
    The errors are shown as follows:
    Exception in thread "main" java.lang.NullPointerException
    at guiClient.createActionTable<guiClient.java :191>
    at guiClient.<init> <guiClient.java:52>
    at guiClient.main <guiClient.java:308>
    Here is the whole code for the syntax but it cannot be compiled:
    /* * My GUI Client */
    import javax.swing.*;
    import javax.swing.text.*;
    import java.awt.*;
    //for HTML Headers
    import javax.swing.text.StyledEditorKit.*;
    import javax.swing.text.html.HTMLEditorKit.*;
    import javax.swing.text.html.*;
    import javax.swing.event.HyperlinkListener;
    import javax.swing.event.HyperlinkEvent;
    import javax.swing.event.HyperlinkEvent.EventType;
    import javax.swing.text.html.HTMLFrameHyperlinkEvent;
    import javax.swing.text.*;
    //for layout managers
    import java.awt.event.*;
    //for action and window events
    import java.io.*;
    import java.net.*;
    import java.awt.GraphicsEnvironment;
    import java.util.HashMap;
    public class guiClient extends JFrame implements ActionListener {
    protected static final String textFieldString = "JTextField";
    protected static final String loadgraphicString = "LoadGraphic";
    protected static final String connectString = "Connect";
    static JEditorPane editorPane;
    static JPanel layoutPanel = new JPanel(new BorderLayout());
    static JPanel controlPanel = new JPanel(new BorderLayout());
    static PrintStream out;
    static DrawPanel dPanel;
    static DrawControls dControls;
    static AnimationButtons aControls;
    static String userString;
    static JTextField userName = new JTextField();
    public static JMenuBar menuBar;
    private static JButton connectbutton = new JButton("Connect");
    static boolean CONNECTFLAG = false;
    AbstractDocument doc;
    HashMap actions;
    //create the gui interface
    public guiClient() {
         super("My Client");
    //Create a regular text field.
         JTextField textField = new JTextField(10);
         textField.setActionCommand(textFieldString);
         textField.addActionListener(this);
    //Create an editor pane.
        createActionTable(editorPane); //From TextComponentDemo
        editorPane = new JEditorPane();
         editorPane.setContentType("text");
         editorPane.setEditable(true);
    //set up HTML editor kit
         HTMLDocument m_doc = new HTMLDocument();
         editorPane.setDocument(m_doc);
         HTMLEditorKit hkit = new HTMLEditorKit();
         editorPane.setEditorKit( hkit );
         editorPane.addHyperlinkListener(new HyperListener());
    //Create whiteboard
            dPanel = new DrawPanel();
            dControls = new DrawControls(dPanel);
            aControls = new AnimationButtons (dPanel);
            JPanel whiteboard = new JPanel();
            whiteboard.setLayout(new BorderLayout());
            whiteboard.setPreferredSize(new Dimension(300,300));
            whiteboard.add("Center",dPanel);
            whiteboard.add("South",dControls);
           // whiteboard.add("North",aControls);
         JScrollPane editorScrollPane = new JScrollPane(editorPane);
         editorScrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
         editorScrollPane.setPreferredSize(new Dimension(250, 145));
         editorScrollPane.setMinimumSize(new Dimension(50, 50));
    //     StyledDocument styledDoc = editorPane.getStyledDocument();
    //put everything in a panel
         JPanel contentPane = new JPanel();
         contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
    //add whiteboard
         contentPane.add(whiteboard);
    //add editor box
         contentPane.add(editorScrollPane);
    //add spacer
         contentPane.add(Box.createRigidArea(new Dimension(0,5)));
    //add textfield
         contentPane.add(textField);
    //set up layout pane
         layoutPanel.add(BorderLayout.WEST,new Label("Name: ")); //add a label
         layoutPanel.add(BorderLayout.CENTER, userName ); //add textfield for user names
         layoutPanel.add(BorderLayout.SOUTH, connectbutton);//add dropdown box for fonts
         contentPane.add(layoutPanel);
         contentPane.add(controlPanel);
         contentPane.add(aControls);
    //Create the menu bar.
            menuBar = new JMenuBar();
            setJMenuBar(menuBar);
    //Build the first menu.
         JMenu menu = new JMenu("File");
         JMenu styleMenu = createStyleMenu();
         menu.setMnemonic(KeyEvent.VK_F);
         menuBar.add(menu);
         menuBar.add(styleMenu);
    //a group of JMenuItems
         JMenuItem menuItem = new JMenuItem("Load Graphic", KeyEvent.VK_L);
         menu.add(menuItem);
            menuItem.setActionCommand(loadgraphicString);
         menuItem.addActionListener(this);
            connectbutton.setActionCommand(connectString);
            connectbutton.addActionListener(this);
         setContentPane(contentPane);
    protected JMenu createStyleMenu() {
            JMenu menu = new JMenu("Style");
            Action action = new StyledEditorKit.BoldAction();
            action.putValue(Action.NAME, "Bold");
            menu.add(action);
            action = new StyledEditorKit.ItalicAction();
            action.putValue(Action.NAME, "Italic");
            menu.add(action);
            action = new StyledEditorKit.UnderlineAction();
            action.putValue(Action.NAME, "Underline");
            menu.add(action);
            menu.addSeparator();
            menu.add(new StyledEditorKit.FontSizeAction("12", 12));
            menu.add(new StyledEditorKit.FontSizeAction("14", 14));
            menu.add(new StyledEditorKit.FontSizeAction("18", 18));
            menu.addSeparator();
            menu.add(new StyledEditorKit.FontFamilyAction("Serif",
                                                          "Serif"));
            menu.add(new StyledEditorKit.FontFamilyAction("SansSerif",
                                                          "SansSerif"));
            menu.addSeparator();
            menu.add(new StyledEditorKit.ForegroundAction("Red",
                                                          Color.red));
            menu.add(new StyledEditorKit.ForegroundAction("Green",
                                                          Color.green));
            menu.add(new StyledEditorKit.ForegroundAction("Blue",
                                                          Color.blue));
            menu.add(new StyledEditorKit.ForegroundAction("Black",
                                                          Color.black));
            return menu;
         protected SimpleAttributeSet[] initAttributes(int length) {
            //Hard-code some attributes.
            SimpleAttributeSet[] attrs = new SimpleAttributeSet[length];
            attrs[0] = new SimpleAttributeSet();
            StyleConstants.setFontFamily(attrs[0], "SansSerif");
            StyleConstants.setFontSize(attrs[0], 16);
            attrs[1] = new SimpleAttributeSet(attrs[0]);
            StyleConstants.setBold(attrs[1], true);
            attrs[2] = new SimpleAttributeSet(attrs[0]);
            StyleConstants.setItalic(attrs[2], true);
            attrs[3] = new SimpleAttributeSet(attrs[0]);
            StyleConstants.setFontSize(attrs[3], 20);
            attrs[4] = new SimpleAttributeSet(attrs[0]);
            StyleConstants.setFontSize(attrs[4], 12);
            attrs[5] = new SimpleAttributeSet(attrs[0]);
            StyleConstants.setForeground(attrs[5], Color.red);
            return attrs;
        private void createActionTable(JTextComponent textComponent) {
            actions = new HashMap();
            Action[] actionsArray = textComponent.getActions();
            for (int i = 0; i < actionsArray.length; i++) {
                Action a = actionsArray;
    actions.put(a.getValue(Action.NAME), a);
    private Action getActionByName(String name) {
    return (Action)(actions.get(name));
    static private void insertTheHTML(JEditorPane editor, String html, int location) throws IOException {
         HTMLEditorKit kit = (HTMLEditorKit) editor.getEditorKit();
         Document doc = editor.getDocument();
         StringReader reader = new StringReader(html);
         try {
              kit.read(reader, doc, location);
         } catch (BadLocationException e) {}
    //listen for actions being performed and process them
    public void actionPerformed(ActionEvent e) {
    //if the action is from the textfield (e.g. user hits enter)
         if (e.getActionCommand().equals(textFieldString)) {
              JTextField fromUser = (JTextField)e.getSource();
         if (fromUser != null){
    //place user text in editor pane
    //send message to server
                   if (userName.getText() != null) {
                        userString = userName.getText().trim();
                   out.println(userString + ": " + fromUser.getText());
              fromUser.setText("");
         } else if(e.getActionCommand().equals(connectString)) {
              CONNECTFLAG = true;
    } else if (e.getActionCommand().equals(loadgraphicString) ) {
              final JFileChooser fc = new JFileChooser();
              int returnVal = fc.showOpenDialog(this);
              if (returnVal == JFileChooser.APPROVE_OPTION) {
                   File file = fc.getSelectedFile();
                   dPanel.loadImage(file.getAbsolutePath());
                   sendImage(file);
    //append text to the editor pane and put it at the bottom
    public static void appendText(String text) {
         if (text.startsWith("ID ") ) {
              userString = text.substring(3);
         } else if (text.startsWith("DRAW ") ) {
              if (text.regionMatches(5,"LINE",0,4)) {
    dPanel.processLine(text);
         }else if (text.regionMatches(5,"POINTS",0,5)) {
         dPanel.processPoint(text);
         } else if (text.startsWith("IMAGE ") ) {
    int len = (new Integer( text.substring(6, text.indexOf(",")))).intValue();
    //get x and y coordinates
         byte[] data = new byte[ (int)len ];
         int read = 0;
    try {
         while (read < len) {
         data = text.getBytes( text.substring(0, len) );
    } catch (Exception e) {}
         Image theImage = null;
         theImage = dPanel.getToolkit().createImage(data);
         dPanel.getToolkit().prepareImage(theImage, -1, -1, dPanel);
         while ((dPanel.getToolkit().checkImage(theImage, -1, -1, dPanel) & dPanel.ALLBITS) == 0) {}
              dPanel.drawPicture(0, 0, theImage);
    } else {
    //set current position in editorPane to the end
              editorPane.setCaretPosition(editorPane.getDocument().getLength());
    //put text into the editorPane
              try {
                   insertTheHTML(editorPane, text, editorPane.getDocument().getLength());
              } catch (IOException e) {}
    } //end of appendText(String)
    public void sendImage(File file) {
    //find length of file
         long len = file.length();
    //read file into byte array
         byte[] byteArray = new byte[(int)len];
         try {
              FileInputStream fstream = new FileInputStream(file);
              if (fstream.read(byteArray) < len) {
    //error could not load file
              } else {
              out.println("IMAGE " + len + ",");
                   out.write(byteArray, 0, (int)len); //write file to stream
         } catch(Exception e){}
    //run the client
    private static void createAndShowGUI() {
    //Make sure we have nice window decorations.
    JFrame.setDefaultLookAndFeelDecorated(true);
    //Create and set up the window.
    final guiClient frame = new guiClient();
    //Display the window.
    frame.pack();
    frame.setVisible(true);
    public static void main(String[] args) {
         String ipAddr=null, portNr=null;
              if (args.length != 2) {
                   System.out.println("USAGE: java guiClient IP_Address port_number");
                   System.exit(0);
              } else {
         ipAddr = args[0];
              portNr = args[1];
              JFrame frame = new guiClient();
              frame.addWindowListener(new WindowAdapter() {
                   public void windowClosing(WindowEvent e) { System.exit(0); }
              frame.pack();
              frame.setVisible(true);
              while(CONNECTFLAG == false){}
    //sames as previous client,
    //set up connection and then listen for messages from the Server
              String socketIP = ipAddr;
              int port = Integer.parseInt(portNr);
    //the IP address of the machine where the server is running
              Socket theSocket = null;
    //communication line to the server
              out = null;
    //for message sending
              BufferedReader in = null;
    //for message receiving
              try {
              theSocket = new Socket(socketIP, port );
    //try to connect
              out = new PrintStream(theSocket.getOutputStream());
                   dPanel.out = out;
    //for client to send messages
              in = new BufferedReader(new InputStreamReader(theSocket.getInputStream()));
                   BufferedReader userIn = new BufferedReader(new InputStreamReader(System.in));
                   String fromServer;
                   while ((fromServer = in.readLine()) != null) {
                   appendText(fromServer);
                   if (fromServer.equals("BYE")) {
                        appendText("Connection Closed");
                        break;
              out.close();
    //close all streams
              in.close();
              theSocket.close();
    //close the socket
         } catch (UnknownHostException e) {
    //if the socket cannot be openned
              System.err.println("Cannot find " + socketIP);
              System.exit(1);
              } catch (IOException e) { //if the socket cannot be read or written
              System.err.println("Could not make I/O connection with " + socketIP);
              System.exit(1);
              javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    createAndShowGUI();
    Can someone tell me what's the problem with the syntax?

    For your nullPointerException, you have to create your textPane before calling createActionTable          editorPane = new JEditorPane();
              createActionTable(editorPane); //From TextComponentDemoAlso, I would like to point out the following :
    - you're creating your guiClient twice in the main method : at the beginning and at the end through the createAndShowGUI.
    - for no apparent reason, all your member fields are declared static.
    - naming conventions : class names must start with a capital letter.

  • [locked] adobe flash player plugin not working in FFox 3.6.8

      I run Windows XP Home fully auto-updated, have IE8+ latest FFox browser 3.6.8, and have installed (as Admin) your Shockwave Flash Player
    and plugin Ver. 10.1.53.64.  FFox Plugin Check says "Up to date".  At least 10 times per day, I get a Javascript alert of "script error" when I try
    to view Flash Content. I have thoroughly researched this prob on your site, but find no answer to my prob, hence this thread.
      Please tell me:
    1. How to fix this, and
    2. Why I should not COMPLETELY block ALL Flash content with freeware tools.
      It would be a pity, because I have 5 MILLION hits on my YouTube (and other .flv/swf- hosted vidsites)....  but I have no option now but to consider
    your latest update unusable and incompatible with my Firefox-secured sys. I did sucessfully dodge your slyly unethical attempt to default-install
      McAfee junkware, as I am responsible for securing quite a few computers in my law firm. I use and regularly update & scan w/:
      AVG Antivirus, Spybot S&D+Teatimer resident, and the free Zonealarm firewall. I have updated my Java and Javascriptscript and always keep
      Javascript turned on. I also run SpywareBlaster and occasional free Kaspersky, Panda, and F-secure Virusscans. I am virus/spyware free.
      I wrote my first line of code in 1968.
      The only problem I and my users have is with YOUR Flash product updates/plugins in FFox,  crashing and generating  a Javascript errmsg.
       You have even completely locke up my computer, which NEVER happens to me unless gates does it. I fear I have fallen for the old trick of
       getting v. 1 of an existing ware, to be patched later, in the evil M$oft way.  If your products only work with M$oft OS's and browsers,
       you are violating the well-known Google Success maxim of "don't be evil!"  And the common-sense rule that content-delivery Netware
       should be Browser- independent. I know you code mostly for intrusive-adware, and have allowed for that. But I am getting VERY tired of seeing
       a Javascrpt errmsg and the words on my FFox browser "The Adobe plug-in has crashed. Send crash report"- which I always do.
       I know Open Source wares are pressing you hard, but yes, the .PDF Reader WAS designed to be the first common format other than ASCII.
       You are falling far short of user-acceptance comapared to days past. Your products are WAY overpriced bloatware. PLEASE don't be the
        Bill Gates of served-out pictorial content, where "it's ALL proprietary". That will kill your sales and inspire freeware-writers more than you can
        believe.  If you fail to fix this bug speedily in your freeware, you will suffer the Fate of Vista. I NEVER buy into a ver.1.0, but you have forced me to,
       and it doesn't work.  Fix it- put out a hotfix or patch, or the WHOLE OPEN SOURCE/SHAREWARE Community of Users like me will not even
       CONSIDER buying your products.  I write for your benefit, not mine. .PDF and Word/.wmv files are NEEDED by users. DON'T BE EVIL!
        HELP me! I've already installed OpenOffice and my next sys's OS will be a flavor of UNIX..  You do business in the WRONG way for 2010-users!
        Or are you copying the outdated, universally hated-by-pros M$oft business-model? In less than a decade of Internet time, there won't even BE a
        Microsoft- except for those who are complete Net-Noobs and can be victimized easily. IE8 is a constantly-patched virus magnet. Please
        DO NOT go down that road.....for your own good.
        The De-Crasher

         Uhhh, whatever, ednob. Take offense at whatever you want to- it's your constitutional Right.
        Yes, it's pretty hard to make all these deep-rooted proggies work together. But I think that's the Coder's job to anticipate, not mine.
         All the secuityware I use is pretty popular.  AND-
         I'm too busy in the courtroom to spend much time as a TOTAL what's-new $product$ nerd.
        I JUST EXPECT MY SYS TO WORK. AND IT IS OBVIOUS THAT ADOBE PLUGIN UPDATE TRIGGERED THE SEVERE PROBLEM
         This answer is that I'd just like my sys to be able to access my weather site Intellicast.com , which my NEW! BETTER! Flash 10
         installation just froze hands-down in the best, latest, most secure browser- FFox. For 15 minutes. That's all I have for you.
          Adios!    You can go away now.  I billmy tim at $200/hr and have lectured by invitation to NASA, DECUS and a whole lot of other folks.
         Been using the Net since 1991- when you HAD to learn UNIX.
        =======================================================================================
        For the man who really tried to HELP me, Syncwulf, here is some error-data I could capture- even with a frozen browser
        I had to kill with Task Manager.
         The message the INTELLICAST SITE reported to me was
       ADOBE FLASH ERROR V. 10
      Error: Error #2058: There was an error decompressing the data.
        at flash.utils::ByteArray/_uncompress()
        at flash.utils::ByteArray/uncompress()
        at MethodInfo-1()
        at flash.events::EventDispatcher/dispatchEventFunction()
        at flash.events::EventDispatcher/dispatchEvent()
        at flash.net::URLLoader/onComplete()
      And naturally it froze before I could even send off a Crash Report to help Adobe.
      Too bad for that other window I had open to a client, eh? Had to end the whole FFox run, all tabs.
      All help appreciated, but all snotty lectures from guys who were wetting their diapers when I was using
      Princeton's IBM 360/91 in 1969 to program in ALGOL 60 will be ignored.
      Thanks, SYNCWULF! Your reply arrived at the speed of electrons thru copper = 9 inches per nanosecond.
      - The DeCrasher

  • Update says, FP 10 ax debug . Is this correct?

    Hi,
    I went to the adobe site to update my flashplayer
    to the 10.1.82. It installed that but the file on my dsktop says -FP 10 ax debug-  Is this right? Is that the update name?
    I dont know alot about this but im learning quickly. my flashplayer has been not letting my daughter in to her virtual pet site and i
    thought maybe the flash needed updated, which it did but i dont know if i downloaded the right thing. Any help would be soo great!
    FYI- my computer is on dial up and it takes sosososo long to download and run anything. Also I have Windows xp 2000,
    IE 7, 

    Does anyone know what this ax debug is or what it does? Now when i got to the online game an "action script error has occurred" comes up.
    What is that and how do i fix it? it says Error 2058 Error decompressing the data 
    at flash.util: : ByteArray/_uncompress
    at flash.util: : ByteArray/uncompress
    at com.mindcandy.utils.colouriser: : Colouriser/prepare Colourise
    at com.mindcandy.utils.colouriser: : Colouriser/colourise
    at com.mindcandy.utils.colouriser: : Colouriser/handleswfloadcomplete

  • How do I change fonts in a Text field ??

    Okay I've tried to implement a JComboBox that allows the user to change fonts in the text field. So far I've tried different methods to do it but to no avail. Could somebodoy here read the programs source code for me and tell me where I went wrong?
    /* * My GUI Client */
    import javax.swing.*;
    import javax.swing.text.*;
    import java.awt.*;
    import javax.swing.event.*;
    //for HTML Headers
    import javax.swing.text.StyledEditorKit.*;
    import javax.swing.text.html.HTMLEditorKit.*;
    import javax.swing.text.html.*;
    import javax.swing.event.HyperlinkListener;
    import javax.swing.event.HyperlinkEvent;
    import javax.swing.event.HyperlinkEvent.EventType;
    import javax.swing.text.html.HTMLFrameHyperlinkEvent;
    //for layout managers
    import java.awt.event.*;
    //for action and window events
    import java.io.*;
    import java.net.*;
    import java.awt.GraphicsEnvironment;
    //for font settings
    import java.lang.Integer;
    import java.util.Vector;
    import java.awt.font.*;
    import java.awt.geom.*;
    public class guiClient extends JFrame implements ActionListener {
    protected static final String textFieldString = "JTextField";
    protected static final String loadgraphicString = "LoadGraphic";
    protected static final String connectString = "Connect";
    static JEditorPane editorPane;
    static JPanel layoutPanel = new JPanel(new BorderLayout());
    static JPanel controlPanel = new JPanel(new BorderLayout());
    static JPanel buttonPanel = new JPanel(new BorderLayout());
    static JPanel fontPanel = new JPanel(new BorderLayout());
    static PrintStream out;
    static DrawPanel dPanel;
    static DrawPanel dPButton;
    static DrawPanel dFonts;
    static DrawControls dControls;
    static DrawButtons dButtons;
    static String userString;
    static String currentFont;
    String fontchoice;
    String fontlist;
    static JTextField userName = new JTextField();
    public static JMenuBar menuBar;
    private static JButton connectbutton = new JButton("Connect");
    static boolean CONNECTFLAG = false;
    //create the gui interface
    public guiClient() {
         super("My Client");
    // Create a ComboBox
    GraphicsEnvironment gEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();
    String envfonts[] = gEnv.getAvailableFontFamilyNames();
    Vector vector = new Vector();
    for ( int i = 1; i < envfonts.length; i++ ) {
    vector.addElement(envfonts);
    JComboBox fontlist = new JComboBox (envfonts);
         fontlist.setSelectedIndex(0);
         fontlist.setEditable(true);
         fontlist.addActionListener(this);
         fontchoice = envfonts[0];     
    //Create a regular text field.
         JTextField textField = new JTextField(10);
         textField.setActionCommand(textFieldString);
         textField.addActionListener(this);          
    //Create an editor pane.
    editorPane = new JEditorPane();
         editorPane.setContentType("text");
         editorPane.setEditable(false);
    //set up HTML editor kit
         HTMLDocument m_doc = new HTMLDocument();
         editorPane.setDocument(m_doc);
         HTMLEditorKit hkit = new HTMLEditorKit();
         editorPane.setEditorKit( hkit );
         editorPane.addHyperlinkListener( new HyperListener());
    //Create whiteboard
    dPanel = new DrawPanel();
    dPButton = new DrawPanel();
    dFonts = new DrawPanel();
    dControls = new DrawControls(dPanel);
    dButtons = new DrawButtons(dPButton);
         //JLable fontLab = new JLabel(fontLable);
    //fontLab.setText("Fonts");
    //Font newFont = getFont().deriveFont(1);
    //fontLab.setFont(newFont);
    //fontLab.setHorizontalAlignment(JLabel.CENTER);
    JPanel whiteboard = new JPanel();
    whiteboard.setLayout(new BorderLayout());
    whiteboard.setPreferredSize(new Dimension(300,300));
    whiteboard.add("Center",dPanel);
    whiteboard.add("South",dControls);
    whiteboard.add("North",dButtons);
         JScrollPane editorScrollPane = new JScrollPane(editorPane);
         editorScrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
         editorScrollPane.setPreferredSize(new Dimension(250, 145));
         editorScrollPane.setMinimumSize(new Dimension(50, 50));
    //put everything in a panel
         JPanel contentPane = new JPanel();
         JPanel fontPane = new JPanel();
         contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
    //add whiteboard
         contentPane.add(whiteboard);
    //add editor box
         contentPane.add(editorScrollPane);
    //add spacer
         contentPane.add(Box.createRigidArea(new Dimension(0,5)));
    //add textfield
         contentPane.add(textField);
    //set up layout pane
         //layoutPanel.add(GridLayout(2,1),fontLab);
         layoutPanel.add( BorderLayout.NORTH, fontlist);     
         layoutPanel.add(BorderLayout.WEST,new Label("Name: ")); //add a label
         layoutPanel.add(BorderLayout.CENTER, userName ); //add textfield for user names
         layoutPanel.add(BorderLayout.SOUTH, connectbutton);//add dropdown box for fonts
         //fontPane.add(BorderLayout.NORTH,fontlist);
         contentPane.add(layoutPanel);
         contentPane.add(controlPanel);
         contentPane.add(buttonPanel);
    //Create the menu bar.
    menuBar = new JMenuBar();
    setJMenuBar(menuBar);
    //Build the first menu.
         JMenu menu = new JMenu("File");
         menu.setMnemonic(KeyEvent.VK_F);
         menuBar.add(menu);
    //a group of JMenuItems
         JMenuItem menuItem = new JMenuItem("Load Graphic", KeyEvent.VK_L);
         menu.add(menuItem);
    menuItem.setActionCommand(loadgraphicString);
         menuItem.addActionListener(this);
    connectbutton.setActionCommand(connectString);
    connectbutton.addActionListener(this);
         setContentPane(contentPane);
    static private void insertTheHTML(JEditorPane editor, String html, int location) throws IOException {
         HTMLEditorKit kit = (HTMLEditorKit) editor.getEditorKit();
         Document doc = editor.getDocument();
         StringReader reader = new StringReader(html);
         try {
              kit.read(reader, doc, location);
         } catch (BadLocationException e) {}
    //listen for actions being performed and process them
    public void actionPerformed(ActionEvent e) {
    //if the action is from the textfield (e.g. user hits enter)
         if (e.getActionCommand().equals(textFieldString)) {
              JTextField fromUser = (JTextField)e.getSource();
         if (fromUser != null){
    //place user text in editor pane
    //send message to server
                   if (userName.getText() != null) {
                        userString = userName.getText().trim();
                   out.println(userString + ": " + fromUser.getText());
              fromUser.setText("");
         } else if(e.getActionCommand().equals(connectString)) {
              CONNECTFLAG = true;
    } else if (e.getActionCommand().equals(loadgraphicString) ) {
              final JFileChooser fc = new JFileChooser();
              int returnVal = fc.showOpenDialog(this);
              if (returnVal == JFileChooser.APPROVE_OPTION) {
                   File file = fc.getSelectedFile();
                   dPanel.loadImage(file.getAbsolutePath());
                   sendImage(file);
         else if (e.getActionCommand().equals(fontlist)){
         JComboBox cb = (JComboBox)e.getSource();
    String newSelection = (String)cb.getSelectedItem();
    currentFont = newSelection;
         userString = currentFont;
    return;
    /*public void itemStateChanged (ItemEvent e) {
    if ( e.getStateChange() != ItemEvent.SELECTED ) {
    return;
    if ( list == fontlist ) {
    fontchoice = (String)fontlist.getSelectedItem();
         userString.changeFont(fontchoice);
    //append text to the editor pane and put it at the bottom
    public static void appendText(String text) {
         if (text.startsWith("ID ") ) {
              userString = text.substring(3);
         } else if (text.startsWith("DRAW ") ) {
              if (text.regionMatches(5,"LINE",0,4)) {
    dPanel.processLine(text);
         }else if (text.regionMatches(5,"POINTS",0,5)) {
         dPanel.processPoint(text);
         } else if (text.startsWith("IMAGE ") ) {
    int len = (new Integer( text.substring(6, text.indexOf(",")))).intValue();
    //get x and y coordinates
         byte[] data = new byte[ (int)len ];
         int read = 0;
    try {
         while (read < len) {
         data = text.getBytes( text.substring(0, len) );
    } catch (Exception e) {}
         Image theImage = null;
         theImage = dPanel.getToolkit().createImage(data);
         dPanel.getToolkit().prepareImage(theImage, -1, -1, dPanel);
         while ((dPanel.getToolkit().checkImage(theImage, -1, -1, dPanel) & dPanel.ALLBITS) == 0) {}
              dPanel.drawPicture(0, 0, theImage);
    } else {
    //set current position in editorPane to the end
              editorPane.setCaretPosition(editorPane.getDocument().getLength());
    //put text into the editorPane
              try {
                   insertTheHTML(editorPane, text, editorPane.getDocument().getLength());
              } catch (IOException e) {}
    } //end of appendText(String)
    public void sendImage(File file) {
    //find length of file
         long len = file.length();
    //read file into byte array
         byte[] byteArray = new byte[(int)len];
         try {
              FileInputStream fstream = new FileInputStream(file);
              if (fstream.read(byteArray) < len) {
    //error could not load file
              } else {
              out.println("IMAGE " + len + ",");
                   out.write(byteArray, 0, (int)len); //write file to stream
         } catch(Exception e){}
    //run the client
    public static void main(String[] args) {
         String ipAddr=null, portNr=null;
              if (args.length != 2) {
                   System.out.println("USAGE: java guiClient IP_Address port_number");
                   System.exit(0);
              } else {
         ipAddr = args[0];
              portNr = args[1];
              JFrame frame = new guiClient();
              frame.addWindowListener(new WindowAdapter() {
                   public void windowClosing(WindowEvent e) { System.exit(0); }
              frame.pack();
              frame.setVisible(true);
              while(CONNECTFLAG == false){}
    //sames as previous client,
    //set up connection and then listen for messages from the Server
              String socketIP = ipAddr;
              int port = Integer.parseInt(portNr);
    //the IP address of the machine where the server is running
              Socket theSocket = null;
    //communication line to the server
              out = null;
    //for message sending
              BufferedReader in = null;
    //for message receiving
              try {
              theSocket = new Socket(socketIP, port );
    //try to connect
              out = new PrintStream(theSocket.getOutputStream());
                   dPanel.out = out;
    //for client to send messages
              in = new BufferedReader(new InputStreamReader(theSocket.getInputStream()));
                   BufferedReader userIn = new BufferedReader(new InputStreamReader(System.in));
                   String fromServer;
                   while ((fromServer = in.readLine()) != null) {
                   appendText(fromServer);
                   if (fromServer.equals("BYE")) {
                        appendText("Connection Closed");
                        break;
              out.close();
    //close all streams
              in.close();
              theSocket.close();
    //close the socket
         } catch (UnknownHostException e) {
    //if the socket cannot be openned
              System.err.println("Cannot find " + socketIP);
              System.exit(1);
              } catch (IOException e) { //if the socket cannot be read or written
              System.err.println("Could not make I/O connection with " + socketIP);
              System.exit(1);
    class HyperListener implements HyperlinkListener {
    public JEditorPane sourcePane;
    public void hyperlinkUpdate(HyperlinkEvent e) {
    if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
    sourcePane = (JEditorPane) e.getSource();
                   if (e instanceof HTMLFrameHyperlinkEvent) {
    HTMLFrameHyperlinkEvent event = (HTMLFrameHyperlinkEvent) e;
                        System.out.println(event.getTarget());
                        HTMLDocument doc = (HTMLDocument) sourcePane.getDocument();
                        doc.processHTMLFrameHyperlinkEvent(event);
    else {
    try {}
    catch (Exception ev){
         ev.printStackTrace();
    Well sorry the source code takes up the whole forum but I need a good feedback from this.

    All right...
    public class guiClient extends JFrame implements ActionListener {
    static String userString;
    static String currentFont;
    String fontchoice;
    String fontlist;
    static JTextField userName = new JTextField();
    public guiClient() {
         super("My Client");
    public guiClient() {
         super("My Client");
    // Create a ComboBox
    GraphicsEnvironment gEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();
    String envfonts[] = gEnv.getAvailableFontFamilyNames();
    Vector vector = new Vector();
    for ( int i = 1; i < envfonts.length; i++ ) {
    vector.addElement(envfonts);
    JComboBox fontlist = new JComboBox (envfonts);
         fontlist.setSelectedIndex(0);
         fontlist.setEditable(true);
         fontlist.addActionListener(this);
         fontchoice = envfonts[0];     
    //Create a regular text field.
         JTextField textField = new JTextField(10);
         textField.setActionCommand(textFieldString);
         textField.addActionListener(this);
    public void actionPerformed(ActionEvent e) {
    //if the action is from the textfield (e.g. user hits enter)
         if (e.getActionCommand().equals(textFieldString)) {
              JTextField fromUser = (JTextField)e.getSource();
         if (fromUser != null){
    //place user text in editor pane
    //send message to server
                   if (userName.getText() != null) {
                        userString = userName.getText().trim();
                   out.println(userString + ": " + fromUser.getText());
              fromUser.setText("");
         else if (e.getActionCommand().equals(fontlist)){
         JComboBox cb = (JComboBox)e.getSource();
    String newSelection = (String)cb.getSelectedItem();
    currentFont = newSelection;
         userString = currentFont;
    return;

  • RE:  InflaterInputStream Question

    Hi All
    I'm trying to decode pdfs at the mintute and have sucessfully managed to extract the objects within the file and their associated streams. Some of these objects are flate compressed and I realise java has the ability to decompress flate so I wrote the following code to do it:
    import java.util.zip.*;
    import java.io.*;
    * @author Razz
    public class deflate
        private static void unCompress(File theFile)
            try
                FileInputStream fis = new FileInputStream(theFile);
                InflaterInputStream iis = new InflaterInputStream(fis);
                FileOutputStream fos = new FileOutputStream(new File("C:\\result.txt"));
                byte [] one = new byte[1];   //I'm intentionally reading and writing one byte at a time
                iis.read(one);
                while((one[0]&0xff)!=-1)
                    fos.write(one);
                    iis.read(one);
            catch(Exception err)
                System.out.println("!! Uncompress error !!");
        public static void main(String [] args)
            unCompress(new File("C:\\0.str"));
    }So the unCompress method takes in a file that is the extracted flate stream from the pdf. My problem is that when this program runs it does not stop, it writes out the decompressed stream and continues to write the same byte(which changes depending on the file) over and over. So as a result once I've killed the process I can end up with a 89byte file that when decompressed is 749MB - I think it's safe to say that flate's not that good. Any ideas where I'm going wrong?
    Thanks in advance

    I figured out what was wrong it kept duplicating the final character. Anyway a better solution seems to be using the Inflate object:
        private static void unCompress(File theFile)
            Inflater inf = new Inflater();
            byte[] input = new byte[1024];
            byte[] output = new byte[1024];
            try
                FileInputStream fin = new FileInputStream(theFile);  //Takes method argument as input file to be decompressed
                FileOutputStream fout = new FileOutputStream("C:\\"+theFile.getName());  //Output of decompressed file
                while(true)
                    int numRead = fin.read(input);
                    if(numRead!=-1)
                        inf.setInput(input, 0, numRead);
                    int numDecompressed = 0;
                    while((numDecompressed = inf.inflate(output,0,output.length))!=0)
                        fout.write(output, 0, numDecompressed);
                    if(inf.finished())
                        break;
                    else if(inf.needsDictionary())
                        System.err.println("!! NEEDS A DICTIONARY !!");
                        break;
                    else if(inf.needsInput())
                        continue;
                fin.close();
                fout.flush();
                fout.close();
                inf.reset();
            catch(IOException e)
                System.err.println(e);
            catch(DataFormatException e)
                System.err.println("!! CORRUPT DATA !!");
                System.err.println(e);
        }

  • ArrayIndexOutOfBoundsException, Response.parseString

    java.lang.ArrayIndexOutOfBoundsException
         at com.sun.mail.iap.Response.parseString(Response.java:391)
         at com.sun.mail.iap.Response.readString(Response.java:320)
         at com.sun.mail.imap.protocol.ENVELOPE.<init>(ENVELOPE.java:96)
         at com.sun.mail.imap.protocol.FetchResponse.parse(FetchResponse.java:127)
         at com.sun.mail.imap.protocol.FetchResponse.<init>(FetchResponse.java:63)
         ...Take a look at Response.java
         b = buffer[index];
         if (b == '"') { // QuotedString
              index++; // skip the quote
              int start = index;
              int copyto = index;
              while ((b = buffer[index]) != '"') {     *** LINE 391
         }               We iincrement index, and try to read from buffer without any size checks.
        index++; // skip the quote
        while ((b = buffer[index]) != '"') {
    {code}
    So if the quoted string was bad formed, e.g. it terminated right after '"', then we would get ArrayIndexOutOfBoundsException error. While comments state that in case of any error it should return 'null' value instead./**
    * Generic parsing routine that can parse out a Quoted-String,
    * Literal or Atom and return the parsed token as a String
    * or a ByteArray. Errors or NIL data will return null.
    private Object parseString(boolean parseAtoms, boolean returnString) {
    Notice, that the same issues can be seen in other places. E.g. in following code we can easy go out of bounds if string has no '}'.while (buffer[index] != '}')
    index++;
    Whould be great it this code can be reviewed and fixed :-)
    Regards,
      - Alex                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Hello you who are still alive here,
    2 years have passed and I tried playing with javax.mail 1.4.6-rc1 (along with gimap 1.4.6-rc1).
    The issue appeared for my GMail account while I was trying to test the library.
    bshannon wrote:
    If anyone is still seeing this exception, I'd love to get the details so I can pass them on to
    Google so they can fix this bug in Gmail.
    Thanks.buffer seems to contain:
    * * 6606 FETCH (X-GM-LABELS ("\Importantt" Notifications "\\Starred"))
    (the rest of buffer is filled with \0, the HTMLiser of the forum seems to break the string quoted here, the actual buffer is:
    [42, 32, 54, 54, 48, 54, 32, 70, 69, 84, 67, 72, 32, 40, 88, 45, 71, 77, 45, 76, 65, 66, 69, 76, 83, 32, 40, 34, 92, 73, 109, 112, 111, 114, 116, 97, 110, 116, 116, 34, 32, 78, 111, 116, 105, 102, 105, 99, 97, 116, 105, 111, 110, 115, 32, 34, 92, 92, 83, 116, 97, 114, 114, 101, 100, 34, 41, 41, 13, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    After some tests, it appears this is related to the fact that I attempt to fetch:
    fp.add(GmailFolder.FetchProfileItem.LABELS);From my INBOX.
    Let me know if I can be of some help.
    Cheers,
    Pierre.

  • 8/7/2012 - Flash Player 11.4 Beta 2

    This beta release provides access to the Flash Player 11.4 runtime for Windows and Mac OS desktop environments. The key features and benefits of Flash Player 11.4 are:
    Concurrency (ActionScript Workers) — This feature enable developers to off-load certain tasks like high-latency operations and long-running computations to “workers”. These background workers run concurrently in order to leverage more machine resources and avoid things like UI freezes and allow content to be more responsive.
    Stage3D constrained mode — A new parameter to Context3D has been introduced called "constrained profile".  Constrained profile allows Stage3D content to run hardware accelerated on more hardware, especially the Intel GMA chipsets. The Starling framework has been updated to be constrained mode ready.
    StageVideo.attachCamera — Provides webcam support for StageVideo. This allows developers to leverage GPU acceleration to render webcam video streams.
    Camera.copyToByteArray/Camera.copyToVector — Allow efficient copy of the video frames pixels to an existing ByteArray or Vector.
    LZMA support for ByteArray — In addition to zlib compression of ByteArray, we are introducing an additional compression type based on LZMA to compress data inside a ByteArray through ByteArray.compress() and ByteArray.uncompress().
    In addition to new features, we continue to address stability and performance issues with Flash Player.  We would like to recommend that everyone that installs the beta releases opts into the automatic updates.  We will be delivering regular updates via the update service during the week, some of these releases will be exclusive to this service.  Please see this post for more details:  8/6/2012 - Flash Player 11.4 Beta Updates
    You can find instructions for getting started with this release here: Flash Player 11.4 Labs Page
    Finally, we encourage you to let us know what you think over on our 11.4 Labs forums

    This beta release provides access to the Flash Player 11.4 runtime for Windows and Mac OS desktop environments. The key features and benefits of Flash Player 11.4 are:
    Concurrency (ActionScript Workers) — This feature enable developers to off-load certain tasks like high-latency operations and long-running computations to “workers”. These background workers run concurrently in order to leverage more machine resources and avoid things like UI freezes and allow content to be more responsive.
    Stage3D constrained mode — A new parameter to Context3D has been introduced called "constrained profile".  Constrained profile allows Stage3D content to run hardware accelerated on more hardware, especially the Intel GMA chipsets. The Starling framework has been updated to be constrained mode ready.
    StageVideo.attachCamera — Provides webcam support for StageVideo. This allows developers to leverage GPU acceleration to render webcam video streams.
    Camera.copyToByteArray/Camera.copyToVector — Allow efficient copy of the video frames pixels to an existing ByteArray or Vector.
    LZMA support for ByteArray — In addition to zlib compression of ByteArray, we are introducing an additional compression type based on LZMA to compress data inside a ByteArray through ByteArray.compress() and ByteArray.uncompress().
    In addition to new features, we continue to address stability and performance issues with Flash Player.  We would like to recommend that everyone that installs the beta releases opts into the automatic updates.  We will be delivering regular updates via the update service during the week, some of these releases will be exclusive to this service.  Please see this post for more details:  8/6/2012 - Flash Player 11.4 Beta Updates
    You can find instructions for getting started with this release here: Flash Player 11.4 Labs Page
    Finally, we encourage you to let us know what you think over on our 11.4 Labs forums

  • LoaderInfo class doesn't dispatch Init and Complete events

    Hi,
    I use the traditional way to download jpeg images (size < 200K) dynamically:
        try {
         contentLoader = new Loader();
         contentLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
         contentLoader.contentLoaderInfo.addEventListener(Event.INIT, onInit);
         contentLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onError);
         contentLoader.loadBytes(loader.data as ByteArray);
        } catch (error:Error) {
           trace (error.toString());
    private function onInit(event:Event):void {
         trace ("onInit");
    private function onLoadComplete(evt:Event):void {
         token.result = (evt.target as LoaderInfo).content as Bitmap;
    I have noticed that sometimes class LoaderInfo doesn't dispatch neither INIT nor COMPLETE event working with the same images. There is no IO_ERROR dispatched as well. All images are small (< 200K).
    I suppose that this is a bug in the Flash Player.

    Okay, at this point I think I can chalk it up to a bad swf file (or a couple, anyway).
    One thing I noticed while stepping through fdb is that after invoking loader.loadBytes, even though the completion event is never triggered, it looks like a new swf is instantiated.  The instantiated movieClip is ~600k, though, which is over 200 times the actual source file size.  Using swfdump from the flex sdk on the swf it looks like the framerate and length parameters were bad.  Like 20k and 600k bad.  I'm guessing the file was incorrectly stored as text at a point.  After checking the source asset and reexporting, my application works as expected (the loaderInfo always triggers a completion event).
    I'm not sure why it works when in an isolated test case.  I end up loading the file the same number of times.  There's definitely a concatenation of circumstances at work.  I guess it's possible if I let it run for an indefinite amount of time the event would have eventually triggered.
    Thanks for the time though.  Hopefully someone else finds this thread helpful.

  • Uncompressing ByteArray

    I'm working through the 'reading a zip file' example on the
    liveDocs site, I've copy and pasted the code exactly and I can get
    the filenames and sizes of the files in the zip file (I'm using an
    air archive instead of a zip archive) fine, but when I call the
    uncompress method on the byteArray I get a reference error saying
    that the variable CompressionAlgorithm cannot be found'
    Why is this happening? there are no spelling mistakes in the
    code or anything because I copied it from the example page, this is
    hugely frustrating....

    Well, there probably IS an error in the example. If you are
    running an HTML-based app, then you probably need to use
    "air.CompressionAlgorithm".

Maybe you are looking for