IO filestream help

hi all
im currently learning basic io classes via the java tutorials i tried to write my own version of the copybyte program (http://java.sun.com/docs/books/tutorial/essential/io/examples/CopyBytes.java)
but im having some problems understanding what did i do wrong here:
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.FileNotFoundException;
class NewClass{
public static void main(String[] args)
  FileInputStream input = null;
  FileOutputStream output = null;
  int c;
try{
  input= new FileInputStream("xo.rtf");
  output= new FileOutputStream("byte.txt");
while((c = input.read())!= -1)
   {output.write(c);
catch(FileNotFoundException filee)
{System.out.println("file not found: " + filee);
catch(IOException exc)
{System.err.println("IO exception caught: " + exc);
finally
   if(input!=null)
     {System.out.println("closing file input stream.");
   try{input.close();}
   catch(IOException e){System.err.println("input closing IO err: "+e);}
    else {System.out.println("file input stream allready closed.");}
   if(output!=null)
    {System.out.println("closing file output stream.");
     try{output.close();}
     catch(IOException e){System.err.println("output closing IO err: "+e);}
   else {System.out.println("uotput stream allready closed.");}
}when i try to compile it i get these errors
ByteCopy.java:3: illegal start of type
import java.io.FileInputStream
^
ByteCopy.java:3: <identifier> expected
import java.io.FileInputStream
                              ^
ByteCopy.java:4: <identifier> expected
import java.io.FileOutoutStream
                               ^
ByteCopy.java:5: <identifier> expected
import java.io.IOException
                          ^
ByteCopy.java:46: reached end of file while parsing
}&#8594;
^
5 errors

are you on windows or unix?
It shouldn't bother the compiler either way... but does your file have the appropriate end-of-line sequence for the operating system.... this is probably a blind ally, but it's all I can think of that might (just might) explain why the compiler is reading line 1 as line 3...
... other that that your program source code file is somehow corrupted... try copying it to the clipboard and pasting it into another file. save it under another directory as the same name, and then try compiling it.

Similar Messages

  • Need help to start a prject

    i am fairly new to JSP. I need to create a form(html,jsp) that interacts with oracle database (help desk ticketing system to input problems). I am using jdeveloper as a software to develop it. Are there any tutorial or some kind of documentation available so that I can start it
    please help
    san

    I am working on a application which uses
    jscripts filestream object for communication with
    server and for data exchange from and to server .
    Earlier the file(database in mdb) sizes were small
    and the application was fine but now file size has
    increased and the table which is transferred through
    this communication gives overflow error while other
    small tables in that same mdb file gets updated ..
    Can you give me idea of whats the problem ,
    and how I rectify it , also tell me whats the
    maximum size of stream file for this type of
    communication ..

  • How do I use a FileStream with an IFilePromise without knowing the File?

    I've finished the implmentation of my project using Async IFilePromises by extending the ByteArray class. I can drag out of my application and files are created by copying bits over the network, etc. The issue I'm running into is that because I used the ByteArray as my dataprovider, files are stored "In-Memory" until the Close event is fired.
    My application routinely copies files around 700 MB and up to 2 GB. The implementation quickly causes out of memory errors. That said, if I change the implementation to use FileStreams then the files are written directly to disk and memory is exactly where I want it to be.
    The issue is that the FileStream requires a File object when it's FileStream.open(File, FileMode) method is called. If I manually create a file and use it, then everything is fine, but doing that defeats the purpose of the FilePromise. I lose all the information about where a person dropped the file.
    So how do I get access to the File object that is created for each FilePromise? I know one is created by inspecting the call stack when the IFilePromise.open() method is called and inspecting the caller MacFilePromiseWrapper._file.
    I've tried simply returning a plain FileStream instead of an extended class in the IFilePromise.open method, but that still gives the same error result when I try to write to the stream (says that the stream isnt open yet).
    I would have expected the MacFilePromiseWrapper / FilePromiseWrapper to intelligently handle the returned IDataProvider and perform any "open" and "close" it needed. Please tell me I'm just missing something obvious. I'm so close to being done with this project and I don't want to have to rewrite this using a native implementation. The performance issues (memory usage) will cause me to do just that if I cant figure this out.
    Thanks for any help,
    Jared

    I have resolved the issues myself.
    I had the idea of an IFilePromise / IDataInput backwards. The way I thought it worked is that what you were "writing to" when you wrote into a ByteArray and fired of progress events was simply a pipe to a file handle on the disk. That's backwards.  What really happens is that the thing you're writing to is a buffer for the IFilePromise. Firing the open/progress/close events let the file system know that it's safe to pull up to IDataInput.bytesAvailable out of your buffer and write that to the disk and the buffer you write to can be a ByteArray, Socket, FileStream, etc.
    The confusion was compounded by my attempts to use FileStream as the IDataInput. What I was doing for "testing purposes" was creating a temporary file and writing my bytes to it. The file handle created by the FilePromise would immediately disappear, so I thought it meant I needed to somehow get access to that handle so I knew where to send my bits using FileStream.open(File, FileMode).
    I was really close, but had a mistake in there.  I was on the right track with opening the FileStrea and using the temporary file, but I opened it with the wrong FileMode.
    I used FileMode.WRITE because I thought I was writing to the disk only. When I switched it to FileMode.UPDATE (which is read/write) then everything worked as I needed it to.
    So to summarize, to use a FileStream as the IDataInput for an IFilePromise you need to:
    Create the FileStream object and return it when the IFilePromise.open is called
    When you get bytes off your network, etc, dispatch the OPEN event
    Open the FileStream object with FileMode.UPDATE and use a temporary file provided by File.createTempFile(), store it for later
    Write bytes to the FileStream and send out the proper ProgressEvent.PROGRESS events
    Dispatch the COMPLETE event when you're done
    the IFilePromise.end() method will be called and you have an opportunity to close your FileStream and to delete the temporary file that was created
    I hope this helps someone that runs into a similar issue.

  • Fairly certain that FileStream.writeObject() and FileStream.readObject() do not function - at all -.

    I've struggled with this since Jan 9th, 2013 (if not longer) and the only conclusion I can come to is that this simply does not function.  No matter what I try and no matter what resource (and I'm finding precious few) I follow to try to implement this within Flash Builder 4.7, Flex SDK 4.6.0 (Build 23201), AIR SDK 3.5, I only succeed in creating a file (with the correct name) that is 123 bytes in size that reads back in as NULL;
    I've tried using ByteArray.writeObject()/readObject() as an intermediary with FileStream.writeBytes()/readBytes(), with no luck.
    I've tried instantiating an object, setting properties and then using that.  I've tried instantiating my correctly formed ValueObject (including the remoteClass alias metadata tag).
    I've tried using -verbatim- the example provided in the top most suggested 'Community Help' resource http://www.switchonthecode.com/tutorials/adobe-air-and-flex-saving-serialized-objects-to-f ile It is worth noting that this solitary example of the procedure/SDK-usage is dated to Flex SDK 3.0 and at least 04/04/2009 (first comment on the article).
    My frustrating hell (one version of many methods attempted) is detailed on StackOverflow (including -all- mxml, as, and trace output), but so far, no assistance has been forthcoming, alas.  This is a severely stripped down and simplified version of what had been a far more complex attempt:
    http://stackoverflow.com/questions/14366911/flex-air-actionscript-mobile-file-writeobject- readobject-always-generates-null-w
    An earlier post* detailing a far more complex attempt interation, with, alas, just as little help (guess this isn't a hot button topic) forthcoming:
    http://stackoverflow.com/questions/14259393/flex-actionscript3-filestream-writeobject-fail s-silently-in-ios-what-am-i-doin
    * I previously suspected that it was only failing from within iOS on an iPad, but the first example (the stripped down version) made it evident that it didn't work in the AIR mobile device simulator (iPad) in the Windows environment, and indeed, didn't work in a non-mobile project in the windows environment AIR launcher.
    I'm at a loss, upset, frustrated, in major trouble with my supervisor/deadlines, etc.
    I would very much appreciate any suggestions/help/confirmation/etc.
    Just to move ahead with development I've opted for a far less preferable solution of writing out both an XML file and a JPG file.  I very much do not like this and very much want to store encapsulated serialized objects locally in the same way I assume will work for storing remotely with AMFPHP (if the project ever gets to that point *sigh*).
    Again.  Would be so grateful for any help.

    I want to add to this post as I marked it as "The Answer" though it does not indeed contain the answer directly, for those who come looking for simliar solutions.
    harUI prompted me to realize that my metadata term needed to be capitalized (RemoteClass instead of remoteClass).  As the metadata tags may be user defined, the compiler throws no errors (or warnings *grumble*)
    package vo
        import flash.display.BitmapData;
       // [remoteClass(alias="PTotmImageVO")] incorrect
       [RemoteClass(alias="PTotmImageVO")]
        public class PTotmImageVO

  • Access Denied error while reading from filestream

    Hi Everyone.
    I have an intranet application that stores files in SQL filestream.
    On my dev machine, everything works like a charm.
    I'm able to upload and store files into SQL filestream (AjaxUpload) and able to downlaod them.
    On the live server, I'm able to upload files, delete them, but when I try to download the file from filestream, I get the following error:
    Access is denied
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    Exception Details: System.ComponentModel.Win32Exception: Access is denied
    Source Error:
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
    Stack Trace:
    [Win32Exception (0x80004005): Access is denied]
    System.Data.SqlTypes.SqlFileStream.OpenSqlFileStream(String path, Byte[] transactionContext, FileAccess access, FileOptions options, Int64 allocationSize) +1465594
    System.Data.SqlTypes.SqlFileStream..ctor(String path, Byte[] transactionContext, FileAccess access, FileOptions options, Int64 allocationSize) +398
    System.Data.SqlTypes.SqlFileStream..ctor(String path, Byte[] transactionContext, FileAccess access) +27
    quotes_GetFileStream.quotes_GetFileStream_Load(Object sender, EventArgs e) +740
    System.Web.UI.Control.LoadRecursive() +71
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3048
    The application pool is set to integrated, V.4.0,  and I use a domain user for the identity authentication back to SQL.
    I gave that user DB_Owner rights to the SQL Database for that application.
    Even tried giving it all the SQL Server Roles, though i still get the above error.
    When I change the Identity username to mine (I have Domain Admin rights), everything works flawlessly on the live server.
    What rights am I missing to give that user so he can read from SQL filestream properly.
    Here is the block of code that gets the file from filestream and pushes it to the browser, maybe I'm missing something here (though once i modify the user it works great).
    Dim RecId As Integer = -1
    If Not IsNothing(Request.QueryString("ID")) And IsNumeric(Request.QueryString("ID")) Then
    RecId = CType(Request.QueryString("ID"), Integer)
    End If
    Dim ConString As String = ConfigurationManager.ConnectionStrings("ConnectionString").ToString
    Using Con As SqlConnection = New SqlConnection(ConString)
    Con.Open()
    Dim txn As SqlTransaction = Con.BeginTransaction()
    Dim Sql As String = "SELECT FileData.PathName() , GET_FILESTREAM_TRANSACTION_CONTEXT() as TransactionContext, [FileName], [FileExtension] FROM [QAttach] where RecId = @RecId"
    Dim cmd As SqlCommand = New SqlCommand(Sql, Con, txn)
    cmd.Parameters.Add("@RecID", Data.SqlDbType.Int).Value = RecId
    Dim Rdr As SqlDataReader = cmd.ExecuteReader()
    While Rdr.Read()
    Dim FilePath As String = Rdr(0).ToString()
    Dim objContext As Byte() = DirectCast(Rdr(1), Byte())
    Dim fname As String = Rdr(2).ToString()
    Dim FileExtension As String = Rdr(3).ToString()
    Dim sfs As SqlFileStream = New SqlFileStream(FilePath, objContext, FileAccess.Read)
    Dim Buffer As Byte() = New Byte(CInt(sfs.Length) - 1) {}
    sfs.Read(Buffer, 0, Convert.ToInt32(Buffer.Length))
    Response.Buffer = True
    Response.Charset = ""
    Response.Cache.SetCacheability(HttpCacheability.NoCache)
    Response.ContentType = FileExtension
    Response.AddHeader("content-disposition", "attachment;filename=" & fname)
    Response.BinaryWrite(Buffer)
    Response.Flush()
    Response.End()
    sfs.Close()
    End While
    End Using
    Thanks.
    Oren

    @William Bosacker:
    Please accept our apologies for any mistreatment.  While there's certainly no legal recourse for posts on an open forum like this, we do take steps to try to keep the forums a pleasant and friendly place to visit, and toward this end, two other moderators
    have already cleaned the thread and have begun to address the abuse.
    Not to defend the manner in which it was addressed, I must still point out that necro posting to a thread (this thread is from late 2013) and proposing your post as an answer are both generally discouraged. Again, I cannot condone the way in which it was
    presented, but I can understand why the other contributors thought something should be said.
    The recommended way to contribute information like this would be to create a new Discussion thread with content something like:
    "I was experiencing XYZ issue and while searching for a resolution I found this thread [link to old thread].  But after trying A, B, and C, I found that the following actually resolved my problem [code snippet].  I thought this might be helpful
    for anyone else with this issue... yada yada"
    In the case of this original thread, the issue was most certainly permission related.  While the underlying network permissions would certainly need to allow that user to access the server, the root problem may well have been within the SQL table permissions
    themselves.  The OP of the original thread really didn't provide enough context to know if they had the internal database permissions set correctly.
    The information you've provided essentially shows one way to set the table permissions, but it isn't necessarily the only way.  Its also possible that the issue could be resolved by modifying permission entries within the SQL manager rather than through
    a particular script file.  So while this information may indeed be helpful to someone in the future, it does not necessarily answer the question of this thread.  Only the OP has enough information to know if this can be applied to their situation;
    and since the thread is several years old and was originally closed by a moderator, there is very little chance that the OP will be back to respond.
    Hopefully this clears the air a little and will allow us all to get back to trying to help the VB development community within the guidelines of the forum.
    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

  • Help with ftp upload problem

    Hi I am using a ftp class (known as FTPConnection) that i found on this site: http://www.nsftools.com/tips/JavaFtp.htm , and they only have an example of how to download a File through FTP and not upload one. I am in the proccess of making an FTP upload applet, and need some help on getting upload to work. I also need it to work on both a Pc and mac, so that may be attributing to the problem becuase i am currently on a mac which uses file:// instead of C:\\. Ill post the ftp class, and a snippet of my code that tries to upload a selected file.
    FTPConnection
    /* <!-- in case someone opens this in a browser... --> <pre> */
    * File:   FTPConnection.java
    * Author: Bret Taylor <[email protected]>
    * URL: http://www.stanford.edu/~bstaylor/cs/ftpconnection/FTPConnection.java.shtml
    * see also <a href="http://www.nsftools.com/tips/JavaFtp.htm">http://www.nsftools.com/tips/JavaFtp.htm</a>
    * $Id$
    * Parts of this code were adopted from a variety of other FTP classes the
    * author has encountered that he was not completely satisfied with.  If you
    * think more thanks are due to any particular author than is given, please
    * let him know.  With that caveat, this class can be freely distributed and
    * modified as long as Bret Taylor is given credit in the source code comments.
    * Modified by Julian Robichaux -- http://www.nsftools.com
    * Added constructors, logout(), listFiles(), listSubdirectories(), getAndParseDirList(),
    * processFileListCommand(), and overloaded getFullServerReply().
    * Also added StringBuffer parameter options to transferData() and executeDataCommand()
    * and did a few other little things.
    import java.io.*;
    import java.net.*;
    import java.util.*;
    * <p>A wrapper for the network and command protocols needed for the most common
    * FTP commands.  Standard usage looks something like this:</p>
    * <pre> FTPConnection connection = new FTPConnection();
    * try {
    *     if (connection.connect(host)) {
    *         if (connection.login(username, password)) {
    *             connection.downloadFile(serverFileName);
    *             connection.uploadFile(localFileName);
    *         connection.disconnect();
    * } catch (UnknownHostException e) {
    *     // handle unknown host
    * } catch (IOException e) {
    *     // handle I/O exception
    * }</pre>
    * <p>Most FTP commands are wrapped by easy-to-use methods, but in case clients
    * need more flexibility, you can execute commands directly using the methods
    * <a href="#executeCommand(java.lang.String)">executeCommand</a> and
    * <a href="#executeDataCommand(java.lang.String,
    * java.io.OutputStream)">executeDataCommand</a>,
    * the latter of which is used for commands that require an open data port.</p>
    * @author Bret Taylor
    * @author Julian Robichaux
    * @version 1.01
    public class FTPConnection extends Object {
         * If this flag is on, we print out debugging information to stdout during
         * execution.  Useful for debugging the FTP class and seeing the server's
         * responses directly.
        private static boolean PRINT_DEBUG_INFO = false;
         * The socket through which we are connected to the FTP server.
        private Socket connectionSocket = null;
         private String username;
         private String password;
         private String host;
         * The socket output stream.
        private PrintStream outputStream = null;
         * The socket input stream.
        private BufferedReader inputStream = null;
         * The offset at which we resume a file transfer.
        private long restartPoint = 0L;
         * Added by Julian: If this flag is on, we're currently logged in to something.
        private boolean loggedIn = false;
         * Added by Julian: This is the line terminator to use for multi-line responses.
        public String lineTerm = "\n";
         * Added by Julian: This is the size of the data blocks we use for transferring
         * files.
        private static int BLOCK_SIZE = 4096;
         * Added by Julian: After you create an FTPConnection object, you will call the
         * connect() and login() methods to access your server. Please don't forget to
         * logout() and disconnect() when you're done (it's only polite...).
        public FTPConnection ()
             // default constructor (obviously) -- this is just good to have...
         * Added by Julian: Allows you to specify if you want to send debug output to
         * the console (true if you do, false if you don't).
        public FTPConnection (boolean debugOut)
             PRINT_DEBUG_INFO = debugOut;
         public FTPConnection (String user, String pw, String host_)
             username=user;
              password=pw;
              host=host_;
              PRINT_DEBUG_INFO = false;
         * Prints debugging information to stdout if the private flag
         * <code>PRINT_DEBUG_INFO</code> is turned on.
        private void debugPrint(String message) {
            if (PRINT_DEBUG_INFO) System.err.println(message);
         * Connects to the given FTP host on port f, the default FTP port.
        public boolean connect(String host)
            throws UnknownHostException, IOException
            return connect(host, 21);
         * Connects to the given FTP host on the given port.
        public boolean connect(String host, int port)
            throws UnknownHostException, IOException
            connectionSocket = new Socket(host, port);
              connectionSocket.setSoTimeout(10000);
            outputStream = new PrintStream(connectionSocket.getOutputStream());
            inputStream = new BufferedReader(new
                           InputStreamReader(connectionSocket.getInputStream()));
            if (!isPositiveCompleteResponse(getServerReply())){
                disconnect();
                return false;
            return true;
         * Disconnects from the host to which we are currently connected.
         static boolean URLexists(String URLName)
              try
                   HttpURLConnection.setFollowRedirects(false);
                   // note : you may also need
                   // HttpURLConnection.setInstanceFollowRedirects(false)
                   HttpURLConnection con =
                   (HttpURLConnection) new URL(URLName).openConnection();
                   con.setRequestMethod("HEAD");
                   return (con.getResponseCode() == HttpURLConnection.HTTP_OK);
              catch (Exception e)
                   e.printStackTrace();
                   return false;
         public String getSimpleFileName(File f)
              String path=f.getPath();
              String fileName=path.replace("\\", "/");
              int slashPos = fileName.lastIndexOf("/");
              fileName=fileName.substring(slashPos+1);
              return fileName;
         public String verifyFileName(String name)
              int count=0;
              //String url="http://chris-malcolm.com/images/"+URLEncoder.encode(name).replace("+", "%20");
              while (URLexists("http://chris-malcolm.com/images/"+URLEncoder.encode(name).replace("+", "%20"))==true)
              count++;
              name=FileExt(name)[0]+"-"+count+"."+FileExt(name)[1];
              return name;
         public String[] FileExt(String fileName)
            int dotPos = fileName.lastIndexOf(".");
              fileName=fileName.replace("\\", "/");
              int slashPos = fileName.lastIndexOf("/");
              String extension, name;
              if (slashPos==fileName.length()-1)
                   fileName=fileName.substring(0, fileName.length()-1);
                   slashPos=fileName.lastIndexOf("/");
                   extension="/";
                   name=fileName.substring(slashPos+1);
              else if(dotPos==-1)
                   name=fileName.substring(slashPos+1);
                   extension="";
              else
                   extension = fileName.substring(dotPos+1);
                   name=fileName.substring(slashPos+1, dotPos);
                   String[] output={name, extension};
                   return output;
              String[] output={name, extension};
              return output;
        public void disconnect()
            if (outputStream != null) {
                try {
                      if (loggedIn) { logout(); };
                    outputStream.close();
                    inputStream.close();
                    connectionSocket.close();
                } catch (IOException e) {}
                outputStream = null;
                inputStream = null;
                connectionSocket = null;
         * Wrapper for the commands <code>user [username]</code> and <code>pass
         * [password]</code>.
        public boolean login(String username, String password)
            throws IOException
            int response = executeCommand("user " + username);
            if (!isPositiveIntermediateResponse(response)) return false;
            response = executeCommand("pass " + password);
            loggedIn = isPositiveCompleteResponse(response);
            return loggedIn;
         * Added by Julian: Logout before you disconnect (this is good form).
        public boolean logout()
            throws IOException
            int response = executeCommand("quit");
            loggedIn = !isPositiveCompleteResponse(response);
            return !loggedIn;
         * Wrapper for the command <code>cwd [directory]</code>.
        public boolean changeDirectory(String directory)
            throws IOException
            int response = executeCommand("cwd " + directory);
            return isPositiveCompleteResponse(response);
         * Wrapper for the commands <code>rnfr [oldName]</code> and <code>rnto
         * [newName]</code>.
        public boolean renameFile(String oldName, String newName)
            throws IOException
            int response = executeCommand("rnfr " + oldName);
            if (!isPositiveIntermediateResponse(response)) return false;
            response = executeCommand("rnto " + newName);
            return isPositiveCompleteResponse(response);
         * Wrapper for the command <code>mkd [directory]</code>.
        public boolean makeDirectory(String directory)
            throws IOException
            int response = executeCommand("mkd " + directory);
            return isPositiveCompleteResponse(response);
         * Wrapper for the command <code>rmd [directory]</code>.
        public boolean removeDirectory(String directory)
            throws IOException
            int response = executeCommand("rmd " + directory);
            return isPositiveCompleteResponse(response);
         * Wrapper for the command <code>cdup</code>.
        public boolean parentDirectory()
            throws IOException
            int response = executeCommand("cdup");
            return isPositiveCompleteResponse(response);
         * Wrapper for the command <code>dele [fileName]</code>.
        public boolean deleteFile(String fileName)
            throws IOException
            int response = executeCommand("dele " + fileName);
            return isPositiveCompleteResponse(response);
         * Wrapper for the command <code>pwd</code>.
        public String getCurrentDirectory()
            throws IOException
            String response = getExecutionResponse("pwd");
            StringTokenizer strtok = new StringTokenizer(response);
            // Get rid of the first token, which is the return code
            if (strtok.countTokens() < 2) return null;
            strtok.nextToken();
            String directoryName = strtok.nextToken();
            // Most servers surround the directory name with quotation marks
            int strlen = directoryName.length();
            if (strlen == 0) return null;
            if (directoryName.charAt(0) == '\"') {
                directoryName = directoryName.substring(1);
                strlen--;
            if (directoryName.charAt(strlen - 1) == '\"')
                return directoryName.substring(0, strlen - 1);
            return directoryName;
         * Wrapper for the command <code>syst</code>.
        public String getSystemType()
            throws IOException
            return excludeCode(getExecutionResponse("syst"));
         * Wrapper for the command <code>mdtm [fileName]</code>.  If the file does
         * not exist, we return -1;
        public long getModificationTime(String fileName)
            throws IOException
            String response = excludeCode(getExecutionResponse("mdtm " + fileName));
            try {
                return Long.parseLong(response);
            } catch (Exception e) {
                return -1L;
         * Wrapper for the command <code>size [fileName]</code>.  If the file does
         * not exist, we return -1;
        public long getFileSize(String fileName)
            throws IOException
            String response = excludeCode(getExecutionResponse("size " + fileName));
            try {
                return Long.parseLong(response);
            } catch (Exception e) {
                return -1L;
         * Wrapper for the command <code>retr [fileName]</code>.
        public boolean downloadFile(String fileName)
            throws IOException
            return readDataToFile("retr " + fileName, fileName);
         * Wrapper for the command <code>retr [serverPath]</code>. The local file
         * path to which we will write is given by <code>localPath</code>.
        public boolean downloadFile(String serverPath, String localPath)
            throws IOException
            return readDataToFile("retr " + serverPath, localPath);
         * Wrapper for the command <code>stor [fileName]</code>.
        public boolean uploadFile(String fileName)
            throws IOException
            return writeDataFromFile("stor " + fileName, fileName);
         * Wrapper for the command <code>stor [localPath]</code>. The server file
         * path to which we will write is given by <code>serverPath</code>.
        public boolean uploadFile(String serverPath, String localPath)
            throws IOException
            return writeDataFromFile("stor " + serverPath, localPath);
         * Set the restart point for the next download or upload operation.  This
         * lets clients resume interrupted uploads or downloads.
        public void setRestartPoint(int point)
            restartPoint = point;
            debugPrint("Restart noted");
         * Gets server reply code from the control port after an ftp command has
         * been executed.  It knows the last line of the response because it begins
         * with a 3 digit number and a space, (a dash instead of a space would be a
         * continuation).
        private int getServerReply()
            throws IOException
            return Integer.parseInt(getFullServerReply().substring(0, 3));
         * Gets server reply string from the control port after an ftp command has
         * been executed.  This consists only of the last line of the response,
         * and only the part after the response code.
        private String getFullServerReply()
            throws IOException
            String reply;
            do {
                reply = inputStream.readLine();
                debugPrint(reply);
            } while(!(Character.isDigit(reply.charAt(0)) &&
                      Character.isDigit(reply.charAt(1)) &&
                      Character.isDigit(reply.charAt(2)) &&
                      reply.charAt(3) == ' '));
            return reply;
         * Added by Julian: Returns the last line of the server reply, but also
         * returns the full multi-line reply in a StringBuffer parameter.
        private String getFullServerReply(StringBuffer fullReply)
             throws IOException
            String reply;
            fullReply.setLength(0);
            do {
                reply = inputStream.readLine();
                debugPrint(reply);
                fullReply.append(reply + lineTerm);
            } while(!(Character.isDigit(reply.charAt(0)) &&
                      Character.isDigit(reply.charAt(1)) &&
                      Character.isDigit(reply.charAt(2)) &&
                      reply.charAt(3) == ' '));
              // remove any trailing line terminators from the fullReply
              if (fullReply.length() > 0) 
                   fullReply.setLength(fullReply.length() - lineTerm.length());
            return reply;
         * Added by Julian: Gets a list of files in the current directory.
         public String listFiles()
              throws IOException
              return listFiles("");
         * Added by Julian: Gets a list of files in either the current
         * directory, or one specified as a parameter. The 'params' parameter
         * can be either a directory name, a file mask, or both (such as
         * '/DirName/*.txt').
         public String listFiles(String params)
              throws IOException
              StringBuffer files = new StringBuffer();
              StringBuffer dirs = new StringBuffer();
              if (!getAndParseDirList(params, files, dirs))
                   debugPrint("Error getting file list");
              return files.toString();
         * Added by Julian: Gets a list of subdirectories in the current directory.
         public String listSubdirectories()
              throws IOException
              return listSubdirectories("");
         * Added by Julian: Gets a list of subdirectories in either the current
         * directory, or one specified as a parameter. The 'params' parameter
         * can be either a directory name, a name mask, or both (such as
         * '/DirName/Sub*').
         public String listSubdirectories(String params)
              throws IOException
              StringBuffer files = new StringBuffer();
              StringBuffer dirs = new StringBuffer();
              if (!getAndParseDirList(params, files, dirs))
                   debugPrint("Error getting dir list");
              return dirs.toString();
         * Added by Julian: Sends and gets the results of a file list command,
         * like LIST or NLST.
        private String processFileListCommand(String command)
            throws IOException
            StringBuffer reply = new StringBuffer();
            String replyString;
            // file listings require you to issue a PORT command,
            // like a file transfer
              boolean success = executeDataCommand(command, reply);
              if (!success)
                   return "";
            replyString = reply.toString();
            // strip the trailing line terminator from the reply
            if (reply.length() > 0)
                 return replyString.substring(0, reply.length() - 1);
            }  else  {
                 return replyString;
          * Added by Julian: Gets a directory list from the server and parses
          * the elements into a list of files and a list of subdirectories.
         private boolean getAndParseDirList(String params, StringBuffer files, StringBuffer dirs)
              throws IOException
              // reset the return variables (we're using StringBuffers instead of
              // Strings because you can't change a String value and pass it back
              // to the calling routine -- changing a String creates a new object)
              files.setLength(0);
              dirs.setLength(0);
              // get the NLST and the LIST -- don't worry if the commands
              // don't work, because we'll just end up sending nothing back
              // if that's the case
              String shortList = processFileListCommand("nlst " + params);
              String longList = processFileListCommand("list " + params);
              // tokenize the lists we got, using a newline as a separator
              StringTokenizer sList = new StringTokenizer(shortList, "\n");
              StringTokenizer lList = new StringTokenizer(longList, "\n");
              // other variables we'll need
              String sString;
              String lString;
              // assume that both lists have the same number of elements
              while ((sList.hasMoreTokens()) && (lList.hasMoreTokens())) {
                   sString = sList.nextToken();
                   lString = lList.nextToken();
                   if (lString.length() > 0)
                        if (lString.startsWith("d"))
                             dirs.append(sString.trim() + lineTerm);
                             debugPrint("Dir: " + sString);
                        }  else if (lString.startsWith("-"))  {
                             files.append(sString.trim() + lineTerm);
                             debugPrint("File: " + sString);
                        }  else  {
                             // actually, symbolic links will start with an "l"
                             // (lowercase L), but we're not going to mess with
                             // those
                             debugPrint("Unknown: " + lString);
              // strip off any trailing line terminators and return the values
              if (files.length() > 0)  {  files.setLength(files.length() - lineTerm.length());  }
              if (dirs.length() > 0)  {  dirs.setLength(dirs.length() - lineTerm.length());  }
              return true;
         * Executes the given FTP command on our current connection, returning the
         * three digit response code from the server.  This method only works for
         * commands that do not require an additional data port.
        public int executeCommand(String command)
            throws IOException
            outputStream.println(command);
            return getServerReply();
         * Executes the given FTP command on our current connection, returning the
         * last line of the server's response.  Useful for commands that return
         * one line of information.
        public String getExecutionResponse(String command)
            throws IOException
            outputStream.println(command);
            return getFullServerReply();
         * Executes the given ftpd command on the server and writes the results
         * returned on the data port to the file with the given name, returning true
         * if the server indicates that the operation was successful.
        public boolean readDataToFile(String command, String fileName)
            throws IOException
            // Open the local file
            RandomAccessFile outfile = new RandomAccessFile(fileName, "rw");
            // Do restart if desired
            if (restartPoint != 0) {
                debugPrint("Seeking to " + restartPoint);
                outfile.seek(restartPoint);
            // Convert the RandomAccessFile to an OutputStream
            FileOutputStream fileStream = new FileOutputStream(outfile.getFD());
            boolean success = executeDataCommand(command, fileStream);
            outfile.close();
            return success;
         * Executes the given ftpd command on the server and writes the contents
         * of the given file to the server on an opened data port, returning true
         * if the server indicates that the operation was successful.
        public boolean writeDataFromFile(String command, String fileName)
            throws IOException
            // Open the local file
            RandomAccessFile infile = new RandomAccessFile(fileName, "r");
            // Do restart if desired
            if (restartPoint != 0) {
                debugPrint("Seeking to " + restartPoint);
                infile.seek(restartPoint);
            // Convert the RandomAccessFile to an InputStream
            FileInputStream fileStream = new FileInputStream(infile.getFD());
            boolean success = executeDataCommand(command, fileStream);
            infile.close();
            return success;
         * Executes the given ftpd command on the server and writes the results
         * returned on the data port to the given OutputStream, returning true
         * if the server indicates that the operation was successful.
        public boolean executeDataCommand(String command, OutputStream out)
            throws IOException
            // Open a data socket on this computer
            ServerSocket serverSocket = new ServerSocket(0);
            if (!setupDataPort(command, serverSocket)) return false;
            Socket clientSocket = serverSocket.accept();
            // Transfer the data
            InputStream in = clientSocket.getInputStream();
            transferData(in, out);
            // Clean up the data structures
            in.close();
            clientSocket.close();
            serverSocket.close();
            return isPositiveCompleteResponse(getServerReply());   
         * Executes the given ftpd command on the server and writes the contents
         * of the given InputStream to the server on an opened data port, returning
         * true if the server indicates that the operation was successful.
        public boolean executeDataCommand(String command, InputStream in)
            throws IOException
            // Open a data socket on this computer
            ServerSocket serverSocket = new ServerSocket(0);
            if (!setupDataPort(command, serverSocket)) return false;
            Socket clientSocket = serverSocket.accept();
            // Transfer the data
            OutputStream out = clientSocket.getOutputStream();
            transferData(in, out);
            // Clean up the data structures
            out.close();
            clientSocket.close();
            serverSocket.close();
            return isPositiveCompleteResponse(getServerReply());   
         * Added by Julian: Executes the given ftpd command on the server
         * and writes the results returned on the data port to the given
         * StringBuffer, returning true if the server indicates that the
         * operation was successful.
        public boolean executeDataCommand(String command, StringBuffer sb)
            throws IOException
            // Open a data socket on this computer
            ServerSocket serverSocket = new ServerSocket(0);
            if (!setupDataPort(command, serverSocket)) return false;
            Socket clientSocket = serverSocket.accept();
            // Transfer the data
            InputStream in = clientSocket.getInputStream();
            transferData(in, sb);
            // Clean up the data structures
            in.close();
            clientSocket.close();
            serverSocket.close();
            return isPositiveCompleteResponse(getServerReply());   
         * Transfers the data from the given input stream to the given output
         * stream until we reach the end of the stream.
        private void transferData(InputStream in, OutputStream out)
            throws IOException
            byte b[] = new byte[BLOCK_SIZE];
            int amount;
            // Read the data into the file
            while ((amount = in.read(b)) > 0) {
                out.write(b, 0, amount);
         * Added by Julian: Transfers the data from the given input stream
         * to the given StringBuffer until we reach the end of the stream.
        private void transferData(InputStream in, StringBuffer sb)
            throws IOException
            byte b[] = new byte[BLOCK_SIZE];
            int amount;
            // Read the data into the StringBuffer
            while ((amount = in.read(b)) > 0) {
                sb.append(new String(b, 0, amount));
         * Executes the given ftpd command on the server and writes the results
         * returned on the data port to the given FilterOutputStream, returning true
         * if the server indicates that the operation was successful.
        private boolean setupDataPort(String command, ServerSocket serverSocket)
            throws IOException
            // Send our local data port to the server
            if (!openPort(serverSocket)) return false;
            // Set binary type transfer
            outputStream.println("type i");
            if (!isPositiveCompleteResponse(getServerReply())) {
                debugPrint("Could not set transfer type");
                return false;
            // If we have a restart point, send that information
            if (restartPoint != 0) {
                outputStream.println("rest " + restartPoint);
                restartPoint = 0;
                // TODO: Interpret server response here
                getServerReply();
            // Send the command
            outputStream.println(command);
            return isPositivePreliminaryResponse(getServerReply());
         * Get IP address and port number from serverSocket and send them via the
         * <code>port</code> command to the ftp server, returning true if we get a
         * valid response from the server, returning true if the server indicates
         * that the operation was successful.
        private boolean openPort(ServerSocket serverSocket)
            throws IOException
            int localport = serverSocket.getLocalPort();
            // get local ip address
            InetAddress inetaddress = serverSocket.getInetAddress();
            InetAddress localip;
            try {
                localip = inetaddress.getLocalHost();
            } catch(UnknownHostException e) {
                debugPrint("Can't get local host");
                return false;
            // get ip address in high byte order
            byte[] addrbytes = localip.getAddress();
            // tell server what port we are listening on
            short addrshorts[] = new short[4];
            // problem:  bytes greater than 127 are printed as negative numbers
            for(int i = 0; i <= 3; i++) {
                addrshorts[i] = addrbytes;
    if (addrshorts[i] < 0)
    addrshorts[i] += 256;
    outputStream.println("port " + addrshorts[0] + "," + addrshorts[1] +
    "," + addrshorts[2] + "," + addrshorts[3] + "," +
    ((localport & 0xff00) >> 8) + "," +
    (localport & 0x00ff));
    return isPositiveCompleteResponse(getServerReply());
    * True if the given response code is in the 100-199 range.
    private boolean isPositivePreliminaryResponse(int response)
    return (response >= 100 && response < 200);
    * True if the given response code is in the 300-399 range.
    private boolean isPositiveIntermediateResponse(int response)
    return (response >= 300 && response < 400);
    * True if the given response code is in the 200-299 range.
    private boolean isPositiveCompleteResponse(int response)
    return (response >= 200 && response < 300);
    * True if the given response code is in the 400-499 range.
    private boolean isTransientNegativeResponse(int response)
    return (response >= 400 && response < 500);
    * True if the given response code is in the 500-5

    ok i tried explaining th eproblem in the previous post, but i apologize if my explanation was poor. anyways, i tried to look into it further by doing a printStackTrace() and believe it may be a read error. here is my new updated snippet, and also a link to a screenshot ([click here for screenshot|http://img143.imageshack.us/my.php?image=picture4qr0.png]) of what the error looks like on my end. it seems like a socket is not being read, or maybe it is initialized properly. Again I apologize if my problem is vague, but I do appreciate your input. thanks.
    updated code snippet
    public void uploadFiles()
              statusLabel.setVisible(true);
              errorLabel.setVisible(true);
              uploadButton.setVisible(false);
              footer.setVisible(false);
              holdingPanel.setVisible(false);
              pbar.setVisible(true);
              pbar = new JProgressBar();
              pbar.setMinimum(0);
              float Total=0;
              for (int i=0; i<fileLengths.size(); i++)
                   if(((java.lang.Boolean)model.getValueAt(i,1)).toString().equals("true"))
                        Total+=Float.parseFloat((String)fileLengths.get(i));
              pbar.setMaximum((int)Total);
              String info="";
              try
                   ftp=new FTPConnection(false);
                   ftp.connect("ftp.chris-malcolm.com");
                   if (ftp.login("chrismal", "***"))
                        statusLabel.setText("Status: Connected.");
                        info+="Successfully logged in!\n";
                        info+="System type is: " + ftp.getSystemType()+"\n";
                        info+="Current directory is: " + ftp.getCurrentDirectory()+"\n";
                        if (ftp.changeDirectory("/www/images/"))
                             info+="directory changed to: " + ftp.getCurrentDirectory()+"\n";
                                                 try
                             for (int i=0; i<allFiles.size(); i++)
                                  if(((java.lang.Boolean)model.getValueAt(i,1)).toString().equals("true"))
                                       String f=client.verifyFileName((String)model.getValueAt(i,0));
                                       String f2=""+((File)allFiles.get(i)).getPath();
                                       info+="filename: "+f2+"\n";
                                       if (ftp.uploadFile(f2))
                                            statusLabel.setText("Status: Uploading "+f+" - "+i+" of "+calculateTotalFiles()+" files(s)");
                                            pbar.setValue(Integer.parseInt((String)fileLengths.get(i)));
                                       else
                                            errorLabel.setText("Error occured while uploading"+f2+"\n");
                        catch(Exception de) 
                             StringWriter sw = new StringWriter();
                                  PrintWriter pw = new PrintWriter(sw);
                                  de.printStackTrace(pw);
                                  pw.close();
                                  //errorLabel.setText("<html>ERROR:"+sw.toString().replace("\n", "<br>")+"</html>");
                                  info+="Error: "+de.getMessage()+"\n";
                                  info+="Trace: "+sw+"\n";
                             try { ftp.disconnect(); statusLabel.setText("Status: disconnected.");}  catch(Exception e2)  {};
                        else
                             info+="could not change directory\n";
                   else
                        info+="could not login";
              catch (Exception e)
                   StringWriter sw = new StringWriter();
                                  PrintWriter pw = new PrintWriter(sw);
                                  e.printStackTrace(pw);
                                  pw.close();
                                  info+="Error: "+e.getMessage()+"\n";
                                  info+="Trace: "+sw+"\n";
                   try { ftp.disconnect();  statusLabel.setText("Status: disconnected.");}  catch(Exception e2)  {};
              errorLabel.setText("ERROR:"+info);
              JOptionPane.showMessageDialog(this, info, "test", JOptionPane.PLAIN_MESSAGE);
              try { ftp.disconnect(); statusLabel.setText("Status: disconnected.");}  catch(Exception e2)  {};
         Edited by: cjm771 on Jul 13, 2008 7:23 PM

  • Error creating a file in filestream folder

    So, we have a filestream table that we have been using and copying a significant number of image file into over the past month (about 6 million).  So far, the copying has been going well but have run into a problem which I cannot find an explanation
    or cure. 
    When I try to create a new folder, I am getting the following message:
    An unexpected error is keeping you from creating the folder.  If you continue to receive this error, you can use the error code to search for help with this problem. 
    Error 0x8007013D: The system cannot find message text for message number 0x%1 in the message file for %2
    Any thoughts?

    Hi Mark Anthony Erwin,
    Usually, when you can create a new folder to store the FILESTREAM data , you need to enable the XP_CMDSHELL feature on SQL Server, then create a FILESTREAM enabled database, and create a table with FILESTREAM columns to store FILESTREAM data. Once the FILESTREAM
    table is created successfully, we can  insert any other files to FILESTREAM table via OPENROWSET function, For more information, see:
    http://www.mssqltips.com/sqlservertip/1850/using-insert-update-and-delete-to-manage-sql-server-filestream-data/.
    According to your description, you want to create a new folder in the FILESTREAM folder, you need to check if you don’t set and reconfigure the xp_cmdshell.
    For existing databases, you can use the
    ALTER DATABASE statement to add a FILESTREAM filegroup.
    ALTER DATABASE [FileStreamDataBase]
    ADD FILE (NAME = N'FileStreamDB_FSData2', FILENAME = N'C:\Filestream\FileStreamData2')
    TO FILEGROUP FileStreamGroup
    GO
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • Crawler Help: Object reference not set to an instance of an object

    I'm trying to write a custom crawler and having some difficulties.  I'm getting the document information from a database.  I'm trying to have the ClickThroughURL be a web URL and the IndexingURL be a UNC path to the file on a back-end file share.  Also, I'm not using DocFetch.  The problem I'm having is that when the crawler runs I get the following error for every card:
    &#034;4/19/05 13:43:30- (940) Aborted Card creation for document: TestDoc1.  Import error: IDispatch error #19876 (0x80044fa4): [Error Importing Card.
    Error writing Indexing File.
    SOAP fault: faultcode='soap:Server' faultstring='Server was unable to process request. --> Object reference not set to an instance of an object.']&#034;
    Has anyone seen this before?  Any help you can provide would be greatly appreciated.  I have included the code from my document.vb in case that helps.
    Thanks,
    Jerry
    DOCUMENT.VB
    Imports System
    Imports Plumtree.Remote.Util
    Imports Plumtree.Remote.Crawler
    Imports System.Resources
    Imports System.Globalization
    Imports System.Threading
    Imports System.IO
    Imports System.Data.SqlClient
    Imports System.Text
    Namespace Plumtree.Remote.CWS.MoFoDocsOpen
        Public Class Document
            Implements IDocument
            Private m_logger As ICrawlerLog
            Private DocumentLocation As String
            Private d_DocumentNumber As Integer
            Private d_Library As String
            Private d_Name As String
            Private d_Author As String
            Private d_AuthorID As String
            Private d_Category As String
            Private d_ClientName As String
            Private d_ClientNumber As String
            Private d_DateCreated As DateTime
            Private d_DocumentName As String
            Private d_DocumentType As String
            Private d_EnteredBy As String
            Private d_EnteredByID As String
            Private d_FolderID As String
            Private d_KEFlag As String
            Private d_LastEdit As DateTime
            Private d_LastEditBy As String
            Private d_LastEditByID As String
            Private d_Maintainer As String
            Private d_MaintainerID As String
            Private d_MatterName As String
            Private d_MatterNumber As String
            Private d_Practice As String
            Private d_Description As String
            Private d_Version As Integer
            Private d_Path As String
            Private d_FileName As String
            Public Sub New(ByVal provider As DocumentProvider, ByVal documentLocation As String, ByVal signature As String)
                Dim location() As String = DocumentLocation.Split(&#034;||&#034;)
                Me.DocumentLocation = DocumentLocation
                Me.d_DocumentNumber = location(0)
                Me.d_Library = location(2)
                Dim objConn As New SqlConnection
                Dim objCmd As New SqlCommand
                Dim objRec As SqlDataReader
                objConn.ConnectionString = &#034;Server=sad2525;Database=PortalDocs;Uid=sa;Pwd=;&#034;
                objConn.Open()
                objCmd.CommandText = &#034;SELECT * FROM DocsOpenAggregate WHERE Library = '&#034; & Me.d_Library & &#034;' AND DocumentNumber = &#034; & Me.d_DocumentNumber
                objCmd.Connection = objConn
                objRec = objCmd.ExecuteReader()
                Do While objRec.Read() = True
                    Me.d_Name = objRec(&#034;Name&#034;)
                    Me.d_Author = objRec(&#034;Author&#034;)
                    Me.d_AuthorID = objRec(&#034;AuthorID&#034;)
                    Me.d_Category = objRec(&#034;Category&#034;)
                    Me.d_ClientName = objRec(&#034;ClientName&#034;)
                    Me.d_ClientNumber = objRec(&#034;ClientNumber&#034;)
                    Me.d_DateCreated = objRec(&#034;DateCreated&#034;)
                    Me.d_DocumentName = objRec(&#034;DocumentName&#034;)
                    Me.d_DocumentType = objRec(&#034;DocumentType&#034;)
                    Me.d_EnteredBy = objRec(&#034;EnteredBy&#034;)
                    Me.d_EnteredByID = objRec(&#034;EnteredByID&#034;)
                    Me.d_FolderID = objRec(&#034;FolderID&#034;)
                    Me.d_KEFlag = objRec(&#034;KEFlag&#034;)
                    Me.d_LastEdit = objRec(&#034;LastEdit&#034;)
                    Me.d_LastEditBy = objRec(&#034;LastEditBy&#034;)
                    Me.d_LastEditByID = objRec(&#034;LastEditByID&#034;)
                    Me.d_Maintainer = objRec(&#034;Maintainer&#034;)
                    Me.d_MaintainerID = objRec(&#034;MaintainerID&#034;)
                    Me.d_MatterName = objRec(&#034;MatterName&#034;)
                    Me.d_MatterNumber = objRec(&#034;MatterNumber&#034;)
                    Me.d_Practice = objRec(&#034;Practice&#034;)
                    Me.d_Description = objRec(&#034;Description&#034;)
                    Me.d_Version = objRec(&#034;Version&#034;)
                    Me.d_Path = objRec(&#034;Path&#034;)
                    Me.d_FileName = objRec(&#034;FileName&#034;)
                Loop
                objCmd = Nothing
                If objRec.IsClosed = False Then objRec.Close()
                objRec = Nothing
                If objConn.State <> ConnectionState.Closed Then objConn.Close()
                objConn = Nothing
            End Sub
            'If using DocFetch, this method returns a file path to the document in the backend repository.
            Public Function GetDocument() As String Implements IDocument.GetDocument
                m_logger.Log(&#034;Document.GetDocument called for &#034; & Me.DocumentLocation)
                Return Me.d_Path
            End Function
            'Returns the metadata information about this document.
            Public Function GetMetaData(ByVal aFilter() As String) As DocumentMetaData Implements IDocument.GetMetaData
                m_logger.Log(&#034;Document.GetMetaData called for &#034; & DocumentLocation)
                Dim DOnvp(23) As NamedValue
                DOnvp(0) = New NamedValue(&#034;Author&#034;, Me.d_Author)
                DOnvp(1) = New NamedValue(&#034;AuthorID&#034;, Me.d_AuthorID)
                DOnvp(2) = New NamedValue(&#034;Category&#034;, Me.d_Category)
                DOnvp(3) = New NamedValue(&#034;ClientName&#034;, Me.d_ClientName)
                DOnvp(4) = New NamedValue(&#034;ClientNumber&#034;, Me.d_ClientNumber)
                DOnvp(5) = New NamedValue(&#034;DateCreated&#034;, Me.d_DateCreated)
                DOnvp(6) = New NamedValue(&#034;DocumentName&#034;, Me.d_DocumentName)
                DOnvp(7) = New NamedValue(&#034;DocumentType&#034;, Me.d_DocumentType)
                DOnvp(8) = New NamedValue(&#034;EnteredBy&#034;, Me.d_EnteredBy)
                DOnvp(9) = New NamedValue(&#034;EnteredByID&#034;, Me.d_EnteredByID)
                DOnvp(10) = New NamedValue(&#034;FolderID&#034;, Me.d_FolderID)
                DOnvp(11) = New NamedValue(&#034;KEFlag&#034;, Me.d_KEFlag)
                DOnvp(12) = New NamedValue(&#034;LastEdit&#034;, Me.d_LastEdit)
                DOnvp(13) = New NamedValue(&#034;LastEditBy&#034;, Me.d_LastEditBy)
                DOnvp(14) = New NamedValue(&#034;LastEditByID&#034;, Me.d_LastEditByID)
                DOnvp(15) = New NamedValue(&#034;Maintainer&#034;, Me.d_Maintainer)
                DOnvp(16) = New NamedValue(&#034;MaintainerID&#034;, Me.d_MaintainerID)
                DOnvp(17) = New NamedValue(&#034;MatterName&#034;, Me.d_MatterName)
                DOnvp(18) = New NamedValue(&#034;MatterNumber&#034;, Me.d_MatterNumber)
                DOnvp(19) = New NamedValue(&#034;Practice&#034;, Me.d_Practice)
                DOnvp(20) = New NamedValue(&#034;Description&#034;, Me.d_Description)
                DOnvp(21) = New NamedValue(&#034;Version&#034;, Me.d_Version)
                DOnvp(22) = New NamedValue(&#034;Path&#034;, Me.d_Path)
                DOnvp(23) = New NamedValue(&#034;FileName&#034;, Me.d_FileName)
                Dim metaData As New DocumentMetaData(DOnvp)
                Dim strExt As String = Right(Me.d_FileName, Len(Me.d_FileName) - InStrRev(Me.d_FileName, &#034;.&#034;))
                Select Case LCase(strExt)
                    Case &#034;xml&#034;
                        metaData.ContentType = &#034;text/xml&#034;
                        metaData.ImageUUID = &#034;{F8F6B82F-53C6-11D2-88B7-006008168DE5}&#034;
                    Case &#034;vsd&#034;
                        metaData.ContentType = &#034;application/vnd.visio&#034;
                        metaData.ImageUUID = &#034;{2CEEC472-7CF0-11d3-BB3A-00105ACE365C}&#034;
                    Case &#034;mpp&#034;
                        metaData.ContentType = &#034;application/vnd.ms-project&#034;
                        metaData.ImageUUID = &#034;{8D6D9F50-D512-11d3-8DB0-00C04FF44474}&#034;
                    Case &#034;pdf&#034;
                        metaData.ContentType = &#034;application/pdf&#034;
                        metaData.ImageUUID = &#034;{64FED895-D031-11D2-8909-006008168DE5}&#034;
                    Case &#034;doc&#034;
                        metaData.ContentType = &#034;application/msword&#034;
                        metaData.ImageUUID = &#034;{0C35DD71-6453-11D2-88C3-006008168DE5}&#034;
                    Case &#034;dot&#034;
                        metaData.ContentType = &#034;application/msword&#034;
                        metaData.ImageUUID = &#034;{0C35DD71-6453-11D2-88C3-006008168DE5}&#034;
                    Case &#034;rtf&#034;
                        metaData.ContentType = &#034;text/richtext&#034;
                        metaData.ImageUUID = &#034;{F8F6B82F-53C6-11D2-88B7-006008168DE5}&#034;
                    Case &#034;xls&#034;
                        metaData.ContentType = &#034;application/vnd.ms-excel&#034;
                        metaData.ImageUUID = &#034;{0C35DD72-6453-11D2-88C3-006008168DE5}&#034;
                    Case &#034;xlt&#034;
                        metaData.ContentType = &#034;application/vnd.ms-excel&#034;
                        metaData.ImageUUID = &#034;{0C35DD72-6453-11D2-88C3-006008168DE5}&#034;
                    Case &#034;pps&#034;
                        metaData.ContentType = &#034;application/vnd.ms-powerpoint&#034;
                        metaData.ImageUUID = &#034;{0C35DD73-6453-11D2-88C3-006008168DE5}&#034;
                    Case &#034;ppt&#034;
                        metaData.ContentType = &#034;application/vnd.ms-powerpoint&#034;
                        metaData.ImageUUID = &#034;{0C35DD73-6453-11D2-88C3-006008168DE5}&#034;
                    Case &#034;htm&#034;
                        metaData.ContentType = &#034;text/html&#034;
                        metaData.ImageUUID = &#034;{D2E2D5E0-84C9-11D2-A0C5-0060979C42D8}&#034;
                    Case &#034;html&#034;
                        metaData.ContentType = &#034;text/html&#034;
                        metaData.ImageUUID = &#034;{D2E2D5E0-84C9-11D2-A0C5-0060979C42D8}&#034;
                    Case &#034;asp&#034;
                        metaData.ContentType = &#034;text/plain&#034;
                        metaData.ImageUUID = &#034;{F8F6B82F-53C6-11D2-88B7-006008168DE5}&#034;
                    Case &#034;idq&#034;
                        metaData.ContentType = &#034;text/plain&#034;
                        metaData.ImageUUID = &#034;{F8F6B82F-53C6-11D2-88B7-006008168DE5}&#034;
                    Case &#034;txt&#034;
                        metaData.ContentType = &#034;text/plain&#034;
                        metaData.ImageUUID = &#034;{F8F6B82F-53C6-11D2-88B7-006008168DE5}&#034;
                    Case &#034;log&#034;
                        metaData.ContentType = &#034;text/plain&#034;
                        metaData.ImageUUID = &#034;{F8F6B82F-53C6-11D2-88B7-006008168DE5}&#034;
                    Case &#034;sql&#034;
                        metaData.ContentType = &#034;text/plain&#034;
                        metaData.ImageUUID = &#034;{F8F6B82F-53C6-11D2-88B7-006008168DE5}&#034;
                    Case Else
                        metaData.ContentType = &#034;application/octet-stream&#034;
                        metaData.ImageUUID = &#034;{F8F6B82F-53C6-11D2-88B7-006008168DE5}&#034;
                End Select
                metaData.Name = Me.d_Name
                metaData.Description = Me.d_Description
                metaData.FileName = Me.d_FileName ' This is a file name - for example &#034;2jd005_.DOC&#034;
                metaData.IndexingURL = Me.d_Path ' This is a file path - for example &#034;\\fileserver01\docsd$\SF01\DOCS\MLS1\NONE\2jd005_.DOC&#034;
                metaData.ClickThroughURL = &#034;http://mofoweb/docsopen.asp?Unique=&#034; & HttpUtility.HtmlEncode(Me.DocumentLocation)
                metaData.UseDocFetch = False
                Return metaData
            End Function
            'Returns the signature or last-modified-date of this document that indicates to the portal whether the document needs refreshing.
            Public Function GetDocumentSignature() As String Implements IDocument.GetDocumentSignature
                Dim SigString As New StringBuilder
                Dim SigEncode As String
                SigString.Append(Me.d_DocumentNumber & &#034;||&#034;)
                SigString.Append(Me.d_Library & &#034;||&#034;)
                SigString.Append(Me.d_Name & &#034;||&#034;)
                SigString.Append(Me.d_Author & &#034;||&#034;)
                SigString.Append(Me.d_AuthorID & &#034;||&#034;)
                SigString.Append(Me.d_Category & &#034;||&#034;)
                SigString.Append(Me.d_ClientName & &#034;||&#034;)
                SigString.Append(Me.d_ClientNumber & &#034;||&#034;)
                SigString.Append(Me.d_DateCreated & &#034;||&#034;)
                SigString.Append(Me.d_DocumentName & &#034;||&#034;)
                SigString.Append(Me.d_DocumentType & &#034;||&#034;)
                SigString.Append(Me.d_EnteredBy & &#034;||&#034;)
                SigString.Append(Me.d_EnteredByID & &#034;||&#034;)
                SigString.Append(Me.d_FolderID & &#034;||&#034;)
                SigString.Append(Me.d_KEFlag & &#034;||&#034;)
                SigString.Append(Me.d_LastEdit & &#034;||&#034;)
                SigString.Append(Me.d_LastEditBy & &#034;||&#034;)
                SigString.Append(Me.d_LastEditByID & &#034;||&#034;)
                SigString.Append(Me.d_Maintainer & &#034;||&#034;)
                SigString.Append(Me.d_MaintainerID & &#034;||&#034;)
                SigString.Append(Me.d_MatterName & &#034;||&#034;)
                SigString.Append(Me.d_MatterNumber & &#034;||&#034;)
                SigString.Append(Me.d_Practice & &#034;||&#034;)
                SigString.Append(Me.d_Description & &#034;||&#034;)
                SigString.Append(Me.d_Version & &#034;||&#034;)
                SigString.Append(Me.d_Path & &#034;||&#034;)
                SigString.Append(Me.d_FileName & &#034;||&#034;)
                Dim encoding As New UTF8Encoding
                Dim byteArray As Byte() = encoding.GetBytes(SigString.ToString())
                SigEncode = System.Convert.ToBase64String(byteArray, 0, byteArray.Length)
                Return SigEncode
            End Function
            'Returns an array of the users with access to this document.
            Public Function GetUsers() As ACLEntry() Implements IDocument.GetUsers
                'no acl info retrieved
                Dim aclArray(-1) As ACLEntry
                Return aclArray
            End Function
            'Returns an array of the groups with access to this document.
            Public Function GetGroups() As ACLEntry() Implements IDocument.GetGroups
                'no acl info retrieved
                Dim aclArray(-1) As ACLEntry
                Return aclArray
            End Function
        End Class
    End Namespace

    1. I don't think you can just set the index url to a unc path.
    2. Try creating an index aspx page. In your MetaData.IndexURL set it to the index aspx page, and include query string params for the encoded unc path as well as the content type.
    3. In the index servlet, get the content type and path from the query string
    4. Get the filename from the file path
    5. Set the headers for content-type and Content-Disposition, e.g.
    Response.ContentType="application/msword"
    Response.AddHeader("Content-Disposition", "inline; filename'" + filename)
    6. Stream out the file:
    FileStream fs = new FileStream(path, FileMode.Open)
    byte[] buffer = new byte[40000]
    int result
    System.IO.Stream output = Response.OutputStream
    do
    result = fs.Read(buffer, 0, 40000)
    output.Write(buffer, 0, result)
    while (result == 40000)
    put the above in a try-catch, and then delete the temp file in the finally block.
    If this does not help, set a breakpoint in the code to find the error. Also use Log4Net to log any errors.

  • Help for a Designer

    I have a quad core imac with os 10.7.2.
    I am using Flash Builder 4.5 with the latest AIR sdk.
    I am trying to create an app that can convert and manipulate a collada file.
    Papervision, Flartoolkit and the ColladaAIR Viewer is installed in FB.
    I am using the code in Collada Viewer to design another air app.
    When I open the Main.as that came with Collada Viewer I get no errors.
    But when I copy it to my new src folder I get the following errors:
    1120: Access of undefined property (insert 100 properties from the Collada Viewer)
    I am embarrassed to say how long I have been working on this.
    Its seems as though it can not read the supporting collaviewer.as file.
    What do you do when your files don't access other files?
              This is the script source for the main mxml document called from script source
              (thus why it has no "packaging")
              All graphics, design, and additional programming by: Anthony Scavarelli - http://blog.anthony-scavarelli.com/
              Special thanks to:
              - Fuel Industries for the time to build this. http://www.fuelindustries.com/
              - The Papervision team for their wonderful Papervision classes
              - The Kingnare css and swf control styles by Jin Xin here: http://www.scalenine.com/themes/kingnare/Kingnare.html#
              - Pablo Bandin (http://pablobandin.wordpress.com), for the basis of an animation control class
              - and the many Papervision and Flex resources on teh interwebs for help with the set-up and many problems encountered building this app.
              This application is available for any use, or modeification. I would appreciate any feedback or comments on how you have been able to use it or modify it at it’s original source:
      //the slider controls
              import com.core.ColladaViewer;
              import flash.events.Event;
              import flash.events.MouseEvent;
              import flash.events.OutputProgressEvent;
              import flash.filesystem.*;
              import flash.net.FileFilter;
      //[Embed(
      //source="style/assets/graphics/buttons.swf",
      //symbol="Preloader"
              [Bindable]
        public var _preloader:Class;
              protected var modelOpen:File = new File();
              protected var textureOpen:File = new File();
              protected var txtFilter:FileFilter = new FileFilter("Text", "*.dae;*.DAE;"); //opening models filters
              protected var imageFilter:FileFilter = new FileFilter("Texture", "*.jpg;*.png;"); //texture filters
              protected var _mFileName:String; //model filePath
              protected var _mTextureName:String; //texture filePath
              protected var _modelSelected:Boolean = false;
              protected var _textureSelected:Boolean = false;
      protected var _playButton:Boolean = true; //to keep track of switch from play to pause
      //mouseVars
               protected var _mouseDown:Boolean = false;
              protected var _mouseOver:Boolean = false;
              protected var _mmDown:Boolean = false;
              protected var _mmCountXOld:Number = 0;
              protected var _mmCountYOld:Number = 0;
              protected var _mmCountXNew:Number = 0;
              protected var _mmCountYNew:Number = 0;
              protected var _mmDeltaX:Number = 0;
              protected var _mmDeltaY:Number = 0;
      //second xml window
              public var _xmlWin:XMLWin;
              public var _secondaryWinOpen:Boolean = false;
      public var _daeData:File; //holds dae data for viewing/saving
              public var _daeDataStream:FileStream = new FileStream();
              protected var _modelAnimated:Boolean = false;
      /*********************** initialization *************************/
      protected function init():void {
                        ModelColour.selectedColor = CollView.modColour;
                        WireFrameColour.selectedColor = CollView.wfColour;
      //setting up listeners for closing and minimizing
                        minCloseApp.addEventListener(MinClose.MIN_PRESSED, minApp);
                        minCloseApp.addEventListener(MinClose.CLOSE_PRESSED, closeApp);
      /*********************** end initialization *************************/
      /*********************** event functions *************************/
              protected function closeApp(e:Event):void {
                        minCloseApp.removeEventListener(MinClose.CLOSE_PRESSED, closeApp);
                        NativeApplication.nativeApplication.exit();
              protected function closeSecondWin(e:Event):void {
                        if (_xmlWin != null) {
                                  _xmlWin.close();
                                  _secondaryWinOpen = false;
      //for dragging window
              protected function dragWindow(e:MouseEvent):void {
                        stage.nativeWindow.startMove();
              protected function fileReadHandler(e:Event):void {
                        _daeDataStream.removeEventListener(Event.COMPLETE, fileReadHandler);
      trace("finished reading file");
                        var str:String = _daeDataStream.readUTFBytes(_daeDataStream.bytesAvailable);
                        var lineEndPattern:RegExp = new RegExp(File.lineEnding, "g");
                        str = str.replace(lineEndPattern, "\n");
                        _xmlWin.daeData.text = str;
                        _daeDataStream.close();
                        _xmlWin.reading = false;
              protected function fileWriteHandler(e:OutputProgressEvent):void {
                         _daeDataStream.removeEventListener(OutputProgressEvent.OUTPUT_PROGRESS, fileWriteHandler);
      trace("finished writing");
                         _daeDataStream.close();
                         loadModel();
                         _xmlWin.writing = false;
              protected function getStats():void {
                        Triangles.text = CollView.numTriangles.toString();
                        Vertices.text = CollView.numVertices.toString();
                        Num3DObjects.text = CollView.numVisSceneObjects.toString();
                        ScaleDiff.text = (round(((CollView.currScale * 100)/(CollView.AXIS_LENGTH)),3)).toString();
              protected function initLoadData(e:Event):void {
                        _xmlWin.removeEventListener(XMLWin.CREATION_DONE, initLoadData);
      trace("loading");
                        loadDaeData();
               protected function interactiveMove(e:MouseEvent):void {
      //viewport camera rotations
                         if (_mouseOver && _mouseDown) {
      //if alt is pressed then can "track" or "pan" in case user has only one mouse button
                                   if (CollView.altDown) {
                                             _mmCountXNew = mouseY;
                                            _mmCountYNew = mouseX;
                                            _mmDeltaY = _mmCountXNew - _mmCountXOld;
                                            _mmDeltaX = _mmCountYNew - _mmCountYOld;
                                             CollView.moveCamera(_mmDeltaX/2, _mmDeltaY/2); //move camera
                                   } else {
                                             _mmCountXNew = mouseY;
                                            _mmCountYNew = mouseX;
                                            _mmDeltaX = _mmCountXOld - _mmCountXNew;
                                            _mmDeltaY = _mmCountYOld - _mmCountYNew;
                                             interactiveRotMod(_mmDeltaX, _mmDeltaY); //moving camera "orbit around model"
                        } else if (_mouseOver && _mmDown) {
                         //viewport camera movement x-y tracking
                                  _mmCountXNew = mouseY;
                                  _mmCountYNew = mouseX;
                                   _mmDeltaY = _mmCountXNew - _mmCountXOld;
                                  _mmDeltaX = _mmCountYNew - _mmCountYOld;
                                  CollView.moveCamera(_mmDeltaX/2, _mmDeltaY/2); //move camera
              protected function minApp(e:Event):void {
                        stage.nativeWindow.minimize();
      //middle mouse functions
              protected function mmDown(e:MouseEvent):void {
                        EmptyBox.removeEventListener(MouseEvent.MIDDLE_MOUSE_DOWN, mmDown);
                        EmptyBox.addEventListener(MouseEvent.MIDDLE_MOUSE_UP, mmUp);
                        _mmCountXOld = mouseY;
                        _mmCountYOld = mouseX;
                        _mmDown = true;
                        CollView.camPanning = true;
              protected function mmUp(e:MouseEvent):void {
                        EmptyBox.addEventListener(MouseEvent.MIDDLE_MOUSE_DOWN, mmDown);
                        EmptyBox.removeEventListener(MouseEvent.MIDDLE_MOUSE_UP, mmUp);
                        _mmDown = false;
                        CollView.camPanning = false;
              protected function modelSelected(event:Event):void {
                         var _absPath:String = File(event.target).url;
                         LMText.text = _absPath;
                         _modelSelected = true;
              protected function mouseDown(e:MouseEvent):void {
                        EmptyBox.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
                        stage.addEventListener(MouseEvent.MOUSE_UP, mouseUp);
                        _mouseDown = true;
                        _mmCountXOld = mouseY;
                        _mmCountYOld = mouseX;
                        if (CollView.altDown) {
                                  CollView.camPanning = true;
                        } else {
                                  CollView.camRotating = true;
              protected function mouseOutBox(e:MouseEvent):void {
                        EmptyBox.addEventListener(MouseEvent.MOUSE_OVER, mouseOverBox);
                        EmptyBox.removeEventListener(MouseEvent.MOUSE_OUT, mouseOutBox);
                        _mouseOver = false;
              protected function mouseOverBox(e:MouseEvent):void {
                        EmptyBox.removeEventListener(MouseEvent.MOUSE_OVER, mouseOverBox);
                        EmptyBox.addEventListener(MouseEvent.MOUSE_OUT, mouseOutBox);
                        EmptyBox.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
                        _mouseOver = true
              protected function mouseUp(e:MouseEvent):void {
                        EmptyBox.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
                        stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUp);
                        _mouseDown = false;
                        CollView.camRotating = false;
                        CollView.camPanning = false;
                        CollView.camRotating = false;
              protected function mouseZoom(e:MouseEvent):void {
                        CollView.cameraZoom(e.delta * 5);
                        CollView.camZooming = true;
              protected function reloadModel(e:Event):void {
                        if (_xmlWin != null) {
                                  loadDaeData();
              protected function saveEdits(e:Event):void {
                        if (!CollView.animLoading) {
                                  _xmlWin.writing = true;
      CollView.releaseModel(); //remove references to model (will reload after write)
                                  _daeData = new File(CollView.modelDir);
                            _daeDataStream = new FileStream();
                                  _daeDataStream.openAsync(_daeData, FileMode.WRITE);
                                  _daeDataStream.writeUTFBytes(_xmlWin.daeData.text);
                                  _daeDataStream.addEventListener(OutputProgressEvent.OUTPUT_PROGRESS, fileWriteHandler);
    Thanks Geri

    This is the Acrobat Window forum and Acrobat makes forms differntly than LiveCycle Designer although the saved PDF's can be used by Reader and Acrobat the programs are not interchangable with one another.
    Disabling (graying-out) Form Fields by Thom Parker for a tutorial about enabling/disabling form fields in Acrobat and LiveCycle Designer.
    Here is the link to the LiveCycle Designer forum.

  • Help with event listener

    I'm having some trouble trying to figure out how this event listener will work.
    The main application is building an arrayCollection of a calendarDay custom components which is displayed by a DataGroup.
    Within each calendarDay custom component i may create an arrayList of a DriverDetailComponent custom components displayed within the calendarDay by a DataGroup.
    If a user double clicks on the DriverDetailComponent that is two layers in I would like to change states of the main application.  I'm having trouble figuring out what item in the main application to set the listener on.  Please help.
    I can't figure out how to post the below as scrollable code snips so this is very long.
    Main application code:
    <code><?xml version="1.0" encoding="utf-8"?>
    <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:components="components.*"
                   preinitialize="readDataFile()"
                   creationComplete="buildRowTitles()"
                   width="1024" height="512"  backgroundColor="#A4BDD8">
        <s:states>
            <s:State name="State1"/>
            <s:State name="driverDetailState"/>
        </s:states>
        <!--
        <fx:Style source="EventCalendar.css"/>
        creationComplete="readDataFile()"    creationComplete="driversList.send()"-->
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->       
            <mx:DateFormatter id="myDateFormatter"
                              formatString="EEE, MMM D, YYYY"/>
            <!--<s:HTTPService id="driversList"
                           url="files/drivers.xml"
                           result="driversList_resultHandler(event)"
                           fault="driversList_faultHandler(event)"/>
            <s:HTTPService id="postDriversList"
                           url="files/drivers.xml"
                           method="POST"
                           result="postDriversList_resultHandler(event)"
                />-->
            <!--<s:Move id="expandTab"
                    target="{labelTab}"
                    xBy="250"/>-->
        </fx:Declarations>
        <fx:Script>
            <![CDATA[
                import components.CalendarDay;
                import components.TruckDriver;
                import components.calendarDay;
                import events.CancelChangeDriversEvent;
                import events.ChangeDriversEvent;
                import events.EditDriverEvent;
                import mx.collections.ArrayCollection;
                import mx.collections.ArrayList;
                import mx.containers.Form;
                import mx.controls.Alert;
                import mx.controls.CalendarLayout;
                import mx.core.FlexGlobals;
                import mx.core.IVisualElement;
                import mx.core.WindowedApplication;
                import mx.printing.FlexPrintJob;
                import mx.rpc.events.FaultEvent;
                import mx.rpc.events.ResultEvent;
                import mx.rpc.xml.SimpleXMLEncoder;
                import spark.components.Application;
                import utilities.FormatUtil;
                import utilities.ObjectToXML;
                /* public var prefsFile:File; */ // The preferences prefsFile
                [Bindable] public var driversXML:XML; // The XML data
                public var stream:FileStream; // The FileStream object used to read and write prefsFile data.
                public var fileName:String="driversArrayCollection";
                public var directory:String = "AceTrackerData";
                public var dataFile:File = File.documentsDirectory.resolvePath(directory + "\\" + fileName);
                [Bindable]
                public var drivers:ArrayCollection=new ArrayCollection();
                private var fileStream:FileStream;
                [Bindable]
                public var calendarDayArray:ArrayCollection = new ArrayCollection;
                public var i:int;
                [Bindable]
                public var weekOneTitle:String;
                [Bindable]
                public var weekTwoTitle:String;
                [Bindable]
                public var weekThreeTitle:String;
                [Bindable]
                public var weekFourTitle:String;
                public var day:Object;
                protected function readDataFile():void
                    if(dataFile.exists)
                        fileStream = new FileStream();
                        fileStream.open(dataFile, FileMode.READ);
                        drivers = fileStream.readObject() as ArrayCollection;
                        fileStream.close();
                    else
                        drivers = new ArrayCollection();
                        var driver:TruckDriver = new TruckDriver("New", "Driver", 000);
                        drivers.addItem(driver);
                        saveData(drivers);
                    buildCalendarArray();
                protected function buildCalendarArray():void
                    calendarDayArray.removeAll();
                    for (i=0; i<28; i++)
                        var cd:calendarDay = new calendarDay;
                        cd.dateOffset= i-7
                        cd.drivers=drivers;
                         cd.addEventListener("editDriverEvent",editDriverEvent_Handler);
                        calendarDayArray.addItem(cd);
              private function saveData(obj:Object):void//this is called on the postDriversList result handler to create and write XML data to the file
                    var fs:FileStream = new FileStream();
                    fs.open(dataFile, FileMode.WRITE);
                    /* fs.writeUTFBytes(myXML); */
                    fs.writeObject(drivers);
                    fs.close();
                protected function driverschedule1_changeDriversHandler(event:ChangeDriversEvent):void
                    saveData(drivers); 
                    readDataFile();//i read the drivers file again, this refreshes my data, and removes any temporary data that may have been stored in the drivers array
                    buildCalendarArray();
                    currentState = 'State1';//this hides the driversdetail window after we've clicked save
                    /* postDriversList.send(event.driverInfo); */  //this needs to be different
                    /* Alert.show("TEST"); */
                protected function driverschedule1_cancelChangeDriversHandler(event:CancelChangeDriversEvent):void
                    /* Alert.show("Changes have been canceled."); */
                    readDataFile();//this re-reads the saved data file so that the changes that were made in the pop up window
                    // are no longer reflected if you reopen the window
                    buildCalendarArray();
                    currentState = 'State1';  //this hides the driversdetail window after we've clicked cancel
                protected function buildRowTitles():void
                    var calendarDay0:Object;
                    var calendarDay6:Object;
                    calendarDay0=calendarDayArray.getItemAt(0);
                    calendarDay6=calendarDayArray.getItemAt(6);
                    weekOneTitle = calendarDay0.getDayString() + " - " + calendarDay6.getDayString();
                    weekTwoTitle=calendarDayArray.getItemAt(7).getDayString()+ " - " + calendarDayArray.getItemAt(13).getDayString();
                    weekThreeTitle=calendarDayArray.getItemAt(14).getDayString()+ " - " + calendarDayArray.getItemAt(20).getDayString();
                    weekFourTitle=calendarDayArray.getItemAt(21).getDayString()+ " - " + calendarDayArray.getItemAt(27).getDayString();
            ]]>
        </fx:Script>
        <s:Group height="100%" width="100%">
            <s:layout>
                <s:BasicLayout/>  <!--This is the outermost layout for the main application MXML-->
            </s:layout>
        <s:Scroller width="95%" height="100%"  >
        <s:Group height="100%" width="100%"  ><!--this groups the vertically laid out row titles hoizontally with the large group of calendar days and day titles-->
            <s:layout>
                <s:HorizontalLayout/>
            </s:layout>
        <s:Group height="95%" width="50" ><!--this is the group of row titles layed out vertically-->
            <s:layout>
                <s:VerticalLayout paddingLeft="40" paddingTop="35"/>
            </s:layout>
            <s:Label text="{weekOneTitle}"
                     rotation="-90"
                     backgroundColor="#989393"
                     height="25%" width="115"
                     fontWeight="normal" fontSize="15"
                     paddingTop="4" textAlign="center"  />
            <s:Label text="{weekTwoTitle}"
                     rotation="-90"
                     backgroundColor="#989393"
                     height="25%" width="115"
                     fontWeight="normal" fontSize="15"
                     paddingTop="4" textAlign="center" />
            <s:Label text="{weekThreeTitle}"
                     rotation="-90"
                     backgroundColor="#989393"
                     height="25%" width="115"
                     fontWeight="normal" fontSize="15"
                     paddingTop="4" textAlign="center"  />
            <s:Label text="{weekFourTitle}"
                     rotation="-90"
                     backgroundColor="#989393"
                     height="25%" width="115"
                     fontWeight="normal" fontSize="15"
                     paddingTop="4" textAlign="center"  />
        </s:Group>
        <s:Group height="100%" width="100%" >
            <!--this vertically groups together the horizontal day names group and the tile layout datagroup of calendar days-->
            <s:layout>
                <s:VerticalLayout paddingLeft="5"/>
            </s:layout>
        <s:Group width="100%" >
            <s:layout><!--this group horizontal layout is for the Day names at the top-->
                <s:HorizontalLayout paddingTop="10"/>
            </s:layout>
            <s:Label id="dayNames" text="Sunday" width="16%" fontWeight="bold" fontSize="18" textAlign="center"/>
            <s:Label text="Monday" width="16%" fontWeight="bold" fontSize="18" textAlign="center"/>
            <s:Label text="Tuesday" width="16%" fontWeight="bold" fontSize="18" textAlign="center"/>
            <s:Label text="Wednesday" width="16%" fontWeight="bold" fontSize="18" textAlign="center"/>
            <s:Label text="Thursday" width="16%" fontWeight="bold" fontSize="18" textAlign="center"/>
            <s:Label text="Friday" width="16%" fontWeight="bold" fontSize="18" textAlign="center"/>
            <s:Label text="Saturday" width="16%" fontWeight="bold" fontSize="18" textAlign="center"/>
        </s:Group>
            <!--<s:SkinnableContainer width="16%">-->
                <s:DataGroup id="calendarDataGroup"
                             dataProvider="{calendarDayArray}"
                             itemRenderer="{null}"  resizeMode="scale"
                              height="100%" width="100%"
                              >  <!--  I had to use a null renderer because otherwise each instance is added in a group container renderers.DriverScheduleRenderer-->
                    <s:layout >
                        <s:TileLayout requestedColumnCount="7" />
                    </s:layout>
                </s:DataGroup>
            <!--</s:SkinnableContainer>-->
        <!--<mx:FormItem label="Today's Date:">
            <s:TextInput id="dateToday"
                         text="{myDateFormatter.format(testDate)}"/>
        </mx:FormItem>-->
        <!--<components:DriverSchedule drivers="{drivers}"
                                   changeDriversEvent="driverschedule1_changeDriversHandler(event)"/>-->
            <s:HGroup>  <!--this groups together my drivers button and my print button at the bottom of the calendar-->
            <s:Button id="showDriverDetailButton"
                      label="Driver List"
                      click="currentState = 'driverDetailState'">
                <!--</s:Button>
                <s:Button id="printButton"
                    label="Print"
                    >  click="printButton_clickHandler(event)"-->
                </s:Button>
            </s:HGroup>    <!--this is the end of the small hgroup which pairs my drivers button with the print button-->                  
        </s:Group><!--this ends the vertical grouping of the day names and the tile layout calendar-->   
    </s:Group>        <!--this ends the horizontal grouping of the calendar (names and days) with the week labels at the left-->
        </s:Scroller>
            <s:SkinnableContainer includeIn="driverDetailState"
                                  width="95%" height="95%"  horizontalCenter="0" verticalCenter="0"
                                  backgroundColor="#989898" backgroundAlpha="0.51">
                <s:BorderContainer horizontalCenter="0" verticalCenter="0">
                <components:DriverSchedule id="driverSchedule"
                                            drivers="{drivers}"
                                           changeDriversEvent="driverschedule1_changeDriversHandler(event)"
                                           cancelChangeDriversEvent="driverschedule1_cancelChangeDriversHandler(event)"
                                           />
                </s:BorderContainer>
            </s:SkinnableContainer>
        </s:Group>  <!--end of basic layout group-->
    </s:WindowedApplication>
    </code>
    calendarDay.mxml code:
    <code>
    <?xml version="1.0" encoding="utf-8"?>
    <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
             xmlns:s="library://ns.adobe.com/flex/spark"
             xmlns:mx="library://ns.adobe.com/flex/mx"
             creationComplete="initDay()"
              width="100%">  <!--width="16%" height="25%"  width="160" height="112"-->
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
            <mx:DateFormatter id="myDateFormatter"
                              formatString="MMM D"/>
        </fx:Declarations>
        <fx:Metadata>
            [Event(name = "editDriverEvent", type="events.EditDriverEvent")]
        </fx:Metadata>
        <fx:Script>
            <![CDATA[
                import components.CalendarDay;
                import components.DriverDetailComponent;
                import events.EditDriverEvent;
                import mx.collections.ArrayCollection;
                import mx.collections.ArrayList;
                import mx.controls.CalendarLayout;
                import mx.controls.DateField;
                [Bindable]
                public var todayCollection:ArrayCollection = new ArrayCollection;
                [Bindable]
                public var todayList:ArrayList=new ArrayList; //arraylist created as data provider for dataGroup, this is where all drivers with an arrival date of today are added
                [Bindable]
                public var currDate:Date =new Date; //this will be used to contain the current real world date
                [Bindable]
                public var calDate:Date = new Date; //this is used below to determine the date of the calender day that is being created
                [Bindable] 
                public var todaysDate:CalendarDay;
                [Bindable]
                public var currDay:int;
                [Bindable]
                public var dateOffset:int;
                public var drivers:ArrayCollection= new ArrayCollection();
                   public var driver:Object;  
                public var rowLabel:String;
                public function initDay():void
                    todaysDate  = new CalendarDay(currDate, currDate.day, dateOffset)//currDate represents the day the operating system says today is
                        currDay=todaysDate.returnDate().getDate();//currDay is an int representing the day of the month
                        calDate=todaysDate.returnDate();//calDate represents the actual date on the calendar (MM-DD-YYY) that is currently being evaluated
                        /* if (currDay ==currDate.getDate()) //i want to highlight the day if it is in fact today
                            cont.styleName="Today";
                            if (calDate.getDate() == currDate.getDate())
                            calDayBorder.setStyle("backgroundColor", "#FFFF00");
                        else
                            calDayBorder.setStyle("backgroundColor", "#EEEEEE");
                         addDrivers(); 
                    return;
                  public function addDrivers():void
                       var count:int = 0;
                      /*var driverDetail:DriverDetailComponent;
                      var driver =  */
                    for each (driver in drivers)
                    {//i check the date value based on data entry of mm-dd-yy format against the calculated date for the day
                        //the calender is building and if it is equal the drivers information is added to this day of the calendar
                        if (DateField.stringToDate(driver.arrivalDate,"MM/DD/YYYY").getDate() == calDate.getDate())
                                var driverDetail:DriverDetailComponent = new DriverDetailComponent; //i create a new visual component that adds the id and destination to the calendar day
                                driverDetail.driverid = drivers[count].id; //i feed the id property which is the truck# - firstName
                                driverDetail.driverToLoc=drivers[count].toLoc; //i feed the toLoc which is the current destination of the driver
                                driverDetail.driverArrayLocation=count;   //here i feed the location of this driver in the "drivers" array so i know where it's at for the click listener
                                todayList.addItem(driverDetail);
                            //this concatenates the drivers truck number first name and destination to display in the calendar day
                                /* todayList.addItem(driver.truckNumber + " - " + driver.firstName + " - " + driver.toLoc); */
                    count ++;
                public function getDayString():String
                    rowLabel =myDateFormatter.format(calDate);
                    return rowLabel;
            ]]>
        </fx:Script>
        <s:BorderContainer id="calDayBorder" width="160" styleName="Today" cornerRadius="2" dropShadowVisible="true" height="100%">
            <s:layout>
                <s:BasicLayout/>   
            </s:layout>
            <!--I need to make a custom item renderer for my calendar days that limits the height and width of the day, and also puts the items
            closer together so i can fit maybe 5 drivers on a single day-->
            <s:DataGroup dataProvider="{todayList}"
                         itemRenderer="spark.skins.spark.DefaultComplexItemRenderer"
                         bottom="-2"
                         width="115" left="2">  <!--width="94%"  width="100"  width="16%"-->
                <s:layout >
                    <s:VerticalLayout gap="-4"/> <!--The reduced gap pushes the drivers together if there are serveral on one day. This helps cleanly show several drivers on one day-->
                </s:layout>
            </s:DataGroup >
            <s:Label  text="{currDay}" right="3" top="2" fontSize="14" fontWeight="bold"/>
        </s:BorderContainer>
    </s:Group>
    </code>
    DriverDetailComponent code:
    <code><?xml version="1.0" encoding="utf-8"?>
    <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
             xmlns:s="library://ns.adobe.com/flex/spark"
             xmlns:mx="library://ns.adobe.com/flex/mx">
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
        <fx:Metadata>
            [Event(name = "editDriverEvent", type="events.EditDriverEvent")]
        </fx:Metadata>
        <fx:Script>
            <![CDATA[
                import events.EditDriverEvent;
                import mx.controls.Alert;
                [Bindable]
                public var driverid:String;
                [Bindable]
                public var driverArrayLocation:int;
                [Bindable]
                public var driverToLoc:String;
                protected function label1_doubleClickHandler(event:MouseEvent):void
                    Alert.show("You have selected " +driverid +" at location "  + driverArrayLocation.toString() +" in the drivers ArrayCollection.");
                    var eventObject:EditDriverEvent = new EditDriverEvent("editDriverEvent",driverArrayLocation);
                    dispatchEvent(eventObject);
            ]]>
        </fx:Script>
        <s:Label id="driverDetailLabel" text="{driverid} - {driverToLoc}"  doubleClick="label1_doubleClickHandler(event)" doubleClickEnabled="true"/>
    </s:Group>
    </code>

    lkb3 wrote:
    I'm trying to add a listener to [this JOptionPane pane dialog box|http://beidlers.net/photos/d/516-1/search_screenshot.JPG|my dialog box], so that when it pops up, the cursor is in the text box, but then if the user clicks a button other than the default, the cursor reverts back into the text box.
    The code I have is this:
      // BUILD DIALOG BOX
    JLabel option_label = new JLabel("Select a search option:");
    // Create the button objects
    JRadioButton b1 = new JRadioButton("Search PARTS by name");
    JRadioButton b2 = new JRadioButton("Search ASSEMBLIES by name");
    JRadioButton b3 = new JRadioButton("Search DRAWINGS by name");
    JRadioButton b4 = new JRadioButton("Search all by DESCRIPTION");
    b1.setSelected(true);
    // Tie them together in a group
    ButtonGroup group = new ButtonGroup();
    group.add(b1);
    group.add(b2);
    group.add(b3);
    group.add(b4);
    // Add them to a panel stacking vertically
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel,BoxLayout.Y_AXIS));
    panel.add(b1);
    panel.add(b2);
    panel.add(b3);
    panel.add(b4);
    JLabel name_label = new JLabel("Enter a search term (add *'s as required)");
    JTextField name = new JTextField(30);
    name.addComponentListener(new ComponentListener() {
    public void componentHidden(ComponentEvent ce) { }
    public void componentMoved(ComponentEvent ce) { }
    public void componentResized(ComponentEvent ce) {
    ce.getComponent().requestFocus();
    public void componentShown(ComponentEvent ce) { }
    Object[] array = { option_label, panel, name_label, name };
    // GET INPUT FROM USER
    int res = JOptionPane.showConfirmDialog(null, array, "Select", JOptionPane.OK_CANCEL_OPTION);
    String searchTerm = name.getText();This sucessfully has the focus in the text box when opened; is there a way to get the focus to go back into the text box after the user clicks a radio button?
    Thanks!
    [this JOptionPane pane dialog box|http://beidlers.net/photos/d/516-1/search_screenshot.JPG|dialog Joption]
    you will need to add ItemListener to the JRadioButtons

  • Help with loading image in Air

    Hello there, hope you can help me with this situation.  Getting into FlexSDK/AirSDK development.  I am very familiar with Flex development using Flash Builder 4, however, I would like to get into development using the the two(2) SDK development tools mentioned above especially from an AIR development perspective.  Coming along pretty good, and ran into one problem that driving me nuts: I have an image in a folder called AirSamples/Air/HelloWorld/southwest.jpg.     I tried to bind the image to the image tag by issuing the following:
      <mx:Image source="@Embed('AirSamples/Air/HelloWorld/southwest.jpg')" /> in my mxml file (HelloWorld.mxml). Let assume this is the only component tag in the file.
    When I go to the command prompt and issue the command: amxmlc Helloworld.mxml,  it compiles without an error. When I issue adl HelloWorld-app.mxml   from the command line prompt, it loaded in Flash Player, however,  the graphic symbol came up indicating that a graphic was there, but no graphic. Can you offer any suggestions as to how I can make this work even if I have to use ActionScript.
    Jerry McLeod

    I already know how to do that, but I specifically stated in my post that I can't use the Loader class. The reason for that is that my program is an image manipulation program, and I need to load the data into a BitmapData object. However, since I originally made my post, I have found some more information. I used trace() to find out the length of the ByteArray I was loading the data into, and then the position after trying to create the BitmapData object, like so:
    import flash.display.*;
    import flash.events.*;
    import flash.filesytem.*;
    import flash.net.FileFilter;
    import flash.utils.ByteArray;
    import flash.geom.Rectangle;
    import flash.errors.EOFError;
    var file:File = File.documentsDirectory;
    var myImage:BitmapData;
    var myFilter:FileFilter = new FileFilter("GIF Image","*.gif");
    file.addEventListener(Event.SELECT,loadImage);
    file.browseForOpen("Open",[myFilter]);
    function loadImage(e:Event):void{
         var stream:FileStream = new FileStream();
         stream.open(file,FileMode.READ);
         var bytes:ByteArray = new ByteArray();
         stream.readBytes(bytes);
         stream.close();
         trace(bytes.length); //Outputs: 4631
         //By the way, this image is a special format and will always be 160 by 160 pixels.
         myImage = new BitmapData(160,160);
         bytes.position = 0;
         try{
              myImage.setPixels(new Rectangle(0,0,160,160),bytes);
         } catch(e:EOFError){
              trace(bytes.position); //Outputs: 4628
         addChild(new Bitmap(myImage));
    As the comments show, though the ByteArray is 4631 bytes, it is only read up until byte number 4628. Then it throws an error. Any idea what's going on?

  • ITextSharp PDF library and VB Controls. Need some help ...

    Hi there everybody.
    Mainly for those who are into pdf and in particular iTextSharp library.
    In this example I have a very simple Label control on Form, with text in it.
    I want to build a very simple pdf test file with just one A4 page, and draw Label's Rectangle and Text exactly as I see on Form. Should be a simple task, as I've always read iTextSharp to be quite powerful library. In fact it's not as simple as it seems.
    Here is the code I use for my test :
    Dim fullPdfFileName As String = Application.StartupPath & "\" & "test.pdf"
    'The FileStream
    Dim FS As New System.IO.FileStream(fullPdfFileName, IO.FileMode.Create)
    'The Document
    Dim DOC As New iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 0, 0, 0, 0)
    'The PdfWriter
    Dim PdfW As iTextSharp.text.pdf.PdfWriter = iTextSharp.text.pdf.PdfWriter.GetInstance(DOC, FS)
    DOC.Open()
    'The PdfContentByte
    Dim PdfCB As iTextSharp.text.pdf.PdfContentByte = PdfW.DirectContent
    'Set Stroke properties
    With PdfCB
    .SetRGBColorStroke(255, 0, 0) 'RED
    .SetLineWidth(1)
    End With
    'Draw the Label Rectangle
    Dim X As Integer = GetDotsFromPixels(100)
    Dim Y As Integer = GetDotsFromPixels(100)
    Dim W As Integer = GetDotsFromPixels(lbl_test.Width)
    Dim H As Integer = GetDotsFromPixels(lbl_test.Height)
    PdfCB.Rectangle(X, Y, W, H)
    PdfCB.Stroke()
    'Draw the Label's Text
    Dim BS As iTextSharp.text.pdf.BaseFont = _
    iTextSharp.text.pdf.BaseFont.CreateFont(iTextSharp.text.pdf.BaseFont.HELVETICA, _
    iTextSharp.text.pdf.BaseFont.CP1252, False)
    With PdfCB
    .BeginText()
    .SetFontAndSize(BS, lbl_test.Font.Size)
    .SetTextMatrix(X, Y)
    .ShowText(lbl_test.Text)
    .EndText()
    End With
    DOC.Close()
    FS.Close()
    And this is the very simple GetDotsFromPixels Function that makes 100 Pixels of the Label as one Inch on pdf file and paper, and it works for me :
    Private Function GetDotsFromPixels(ByVal pPixels As Integer) As Integer
    Return Convert.ToInt32(72 / 100 * pPixels)
    End Function
    The output is a pdf file with a red rectangle that is exactly 3 Inches in width and 1 Inch in height, while the Label
    lbl_test is 300x100.
    The problem is the way iTextSharp draws strings and uses Fonts.
    The string is printed in black and in the lower-left corner of the rectangle.
    The Font of the Label is Arial - Bold and top-left aligned, but there's no Arial or many else windows fonts named in BaseFont standard Fonts...
    I need to be able to print out the exact string shown in the label, with its original Font, Size, Color and Position.
    I know X Y coordinates are different with pdf page, and Y = 0 is at the bottom of the page, but if I add rectangle's height to string Y coordinate, then the string would be printed above the rectangle and not inside of it, and I would have to "calculate
    string's height" too...
    Another thing about the Font. iTextSharp's BaseFont seems to lack in properties : where are styles, colors, etc... ?
    Maybe there are others Objects and Methods in the library allowing to do what I want...
    Thanks to everyone able to help.

    Ok, no problem.
    Anyway, I've found myself a possible solution, without any use of the BaseFont.
    It's based on the following Classes/Methods :
    iTextSharp.text.Font
    iTextSharp.text.FontFactory.GetFont()
    iTextSharp.text.pdf.ColumnText
    iTextSharp.text.pdf.ColumnText.SetSimpleColumn()
    I post here the complete code :
    Dim fullPdfFileName As String = Application.StartupPath & "\" & "test.pdf"
    'The FileStream
    Dim FS As New System.IO.FileStream(fullPdfFileName, IO.FileMode.Create)
    'The Document
    Dim DOC As New iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 0, 0, 0, 0)
    'The PdfWriter
    Dim PdfW As iTextSharp.text.pdf.PdfWriter = iTextSharp.text.pdf.PdfWriter.GetInstance(DOC, FS)
    DOC.Open()
    'The PdfContentByte
    Dim PdfCB As iTextSharp.text.pdf.PdfContentByte = PdfW.DirectContent
    'Set Stroke properties
    With PdfCB
    .SetRGBColorStroke(255, 0, 0) 'RED
    .SetLineWidth(1)
    End With
    'Draw the Label Rectangle
    Dim X As Integer = GetDotsFromPixels(200)
    Dim Y As Integer = GetDotsFromPixels(100)
    Dim W As Integer = GetDotsFromPixels(lbl_test.Width)
    Dim H As Integer = GetDotsFromPixels(lbl_test.Height)
    PdfCB.Rectangle(X, Y, W, H)
    PdfCB.Stroke()
    'Draw the Label's Text
    Dim F As iTextSharp.text.Font = iTextSharp.text.FontFactory.GetFont(lbl_test.Font.Name, _
    lbl_test.Font.Size)
    Dim CT As New iTextSharp.text.pdf.ColumnText(PdfCB)
    CT.SetSimpleColumn(New iTextSharp.text.Phrase(lbl_test.Text, F), _
    GetDotsFromPixels(200), _
    GetDotsFromPixels(100), _
    GetDotsFromPixels(200 + lbl_test.Width), _
    GetDotsFromPixels(100 + lbl_test.Height), _
    GetDotsFromPixels(Convert.ToInt32(F.Size) + 5), _
    iTextSharp.text.Element.ALIGN_LEFT)
    CT.Go()
    DOC.Close()
    FS.Close()
    I think this is one of the best ways to put some text with desired font and position.
    Thanks for attention.

  • FileStream problem with AIR deployment

    I use FileStream to load local XML file. When I test the desktop application directly from Flex everything is ok but when I install it with AIR, the application work but the file is not loaded. Here is the code I use:
    import flash.filesystem.*;
     var applicationDirectoryPath:File = File.applicationDirectory; 
    var nativePathToApplicationDirectory:String = applicationDirectoryPath.nativePath.toString(); 
    nativePathToApplicationDirectory +=
    "/config_poste_temps.xml"; 
    var file:File = new File(nativePathToApplicationDirectory); 
    var fs:FileStream = new FileStream(); 
    fs.open(file, FileMode.READ);
    var config:XML = XML(fs.readUTFBytes(fs.bytesAvailable)); 
    fs.close();
    plan.text = config.division;
    Regards

    I am having the same problem as simon_lucas although my config is slightly different:
    FlashBuilder 4 with SDK 4.6, Current app is with SDK 2.5.
    Trying to update with SDK 3.2, I double-checked per Horia Olaru that I do use the application updater swc:
             <path-element>D:\Program Files\Adobe\Adobe Flash Builder 4.6\sdks\4.6.0 - Air 3.2\frameworks\libs\air\applicationupdater.swc</path-element>
             <path-element>D:\Program Files\Adobe\Adobe Flash Builder 4.6\sdks\4.6.0 - Air 3.2\frameworks\libs\air\applicationupdater_ui.swc</path-element>
    But I still have the 16815 error.
    If I change the update.xml to be <update xmlns="http://ns.adobe.com/air/framework/update/description/2.5">
    instead of <update xmlns="http://ns.adobe.com/air/framework/update/description/3.2">, I am proposed to download the new app and then I get an error 16824.
    Please HELP!

  • Filestream Creation Unable to Open Physical File Operating System Error 259

    Hey Everybody,
    I have run out of options supporting a customer that is having an error when creating a database with a file stream.  The error displayed is unable to open physical file operating system error 259 (No more data is available).  We're using a pretty
    standard creation SQL script that we aren't having issues with other customers:
    -- We are going to create our data paths for the filestreams.  
    DECLARE @data_path nvarchar(256);
    SET @data_path = (SELECT SUBSTRING(physical_name, 1, CHARINDEX(N'master.mdf', LOWER(physical_name)) - 1)
                      FROM master.sys.master_files
                      WHERE database_id = 1 AND file_id = 1);
    -- At this point, we should be able to create our database.  
    EXECUTE ('CREATE DATABASE AllTables
    ON PRIMARY
        NAME = AllTables_data
        ,FILENAME = ''' + @data_path + 'AllTables_data.mdf''
        ,SIZE = 10MB
        ,FILEGROWTH = 15%
    FILEGROUP FileStreamAll CONTAINS FILESTREAM DEFAULT
        NAME = FSAllTables
        ,FILENAME = ''' + @data_path + 'AllTablesFS''
    LOG ON
        NAME = AllTables_log
        ,FILENAME = ''' + @data_path + 'AllTables_log.ldf''
        ,SIZE = 5MB
        ,FILEGROWTH = 5MB
    GO
    We are using SQL Server 2014 Express.  File streams were enabled on the installation SQL Server.  The instance was created successfully and we are able to connect to the database through SSMS. The user is using an encrypted Sophos. 
    We have tried the following:
    1. Increasing the permissions of the SQL Server server to have full access to the folders.
    2. Attempted a restore of a blank database and it failed.
    There doesn't seem to be any knowledge base articles on this particular error and I am not sure what else I can do to resolve this.  Thanks in advance for any help!

    Hi Ryan,
    1)SQL Server(any version) can't be installed on encrypted drives. Please see a similar scenario in the following link
    https://ask.sqlservercentral.com/questions/115761/filestream-and-encrypted-drives.html
    2)I don't think there is any problem with permissions on the folder, if the user can create a database in the same folder. Am not too sure. Also see the article by
    Jacob on configuring the FILESTREAM for SQL Server that describes how to configure FILESTREAM access level & creating a FILESTREAM enabled database
    Hope this helps,
    Thanks
    Bhanu 

  • Filestream.write for .jpgs

    Hi,
    i am working on an AIR-Project. The User can load pictures from his computer into the Air-Project. What I want is, to save these pictures automaticly at a certain Folder. I need that because the next time the user is using the Program the picture shall be seen (so i have to have it in a certain Folder)
    I just learned how to create a new document in a certain Folder:
    import flash.filesystem.FileStream;
    import flash.events.Event;
    import flash.filesystem.File;
    import flash.errors.IOError;
    var fileStream:FileStream;
    fileStream = new FileStream();
    fileStream.addEventListener(Event.CLOSE, fileCloseHandler);
    fileStream.addEventListener(IOErrorEvent.IO_ERROR, fileIOError);
    var writeFile:File;
    writeFile = File.documentsDirectory.resolvePath('AIR/test.txt');
    fileStream.openAsync(writeFile, FileMode.WRITE);
    fileStream.writeUTFBytes('Hello World');
    fileStream.close();
    function fileIOError(event:IOErrorEvent):void
    trace ("Sorry did not work");
    function fileCloseHandler(event:Event):void
    trace ("DONE");
    So far so good :-)
    All the Examples i found creating a (.txt) text-file where the content was set by:
    fileStream.writeUTFBytes("Hello World');
    Now i have 2 Problems;
    1) as far as I understand I need to change from "writeUTFBytes" for text-files to something like "writeObject" or "writeBytes" to stream .jpg data - right???
    2) the bigger Problem - I do not know how to let my graphic.data be the content instead of the "Hello World"
    What i have now does work in parts - the first part loads the picture "pic.jpg" / and the second part is a version of the code above that worked well for a .txt
    What does not work is, that I do not get the content of "graphic" into the file to be streamed...
    Here is what i have;
    var graphic:Loader = new Loader();
    var url:URLRequest = new URLRequest("pic.jpg");
    graphic.load(url);
    graphic.contentLoaderInfo.addEventListener(Event.COM PLETE, done);
    addChild(graphic);
    function done(evt:Event)
    trace ("loaded");
    import flash.filesystem.FileStream;
    import flash.filesystem.File;
    import flash.events.Event;
    import flash.filesystem.File;
    import flash.errors.IOError;
    var savethis:File = new File();
    savethis = graphic.data;
    var fileStream:FileStream;
    fileStream = new FileStream();
    fileStream.addEventListener(Event.CLOSE, fileCloseHandler);
    fileStream.addEventListener(IOErrorEvent.IO_ERROR, fileIOError);
    var writeFile:File;
    writeFile = File.documentsDirectory.resolvePath('AIR/pic.jpg');
    fileStream.openAsync(writeFile, FileMode.WRITE);
    fileStream.writeObject(savethis);
    fileStream.close();
    function fileIOError(event:IOErrorEvent):void
    trace ("Did not work");
    function fileCloseHandler(event:Event):void
    trace ("good work");
    Hope you can help me with this!!!
    Try to keep you answer simple - i am not an every-day flasher (looks like I am getting there :-))
    Jan

    I'm having the exact same issue.  I purchased Aperture recently just so I could edit the metadata on lots of old jpg pictures and scans.  Until I upgraded to Lion, it was working well.  Now with Lion, I can still edit the metadata, but I cannot write the metadata back to the master.   I just spent the last two days filling out the metadata info (primarily Title and Caption), figuring to save to master once I got done with the batch of photos I'm currently working on.  I don't want to lose my work. 
    I'm wondering if I can accomplish the same thing by exporting my updated metadata versions and reimporting them.  Might that work?  Will I lose/gain anything in the process? 

Maybe you are looking for