How can i return a file as a Tranferable object

This method bundles up the data to be exported into a Transferable object in preparation for the transfer.*My requirement is to transfer a file as a object.* Here in example it returns a string. So i would like to know how can
we code to transfer a file( NOT FILE NAME).
Example:-
protected Transferable createTransferable(JComponent c) {
// cast component in JList
JList list = (JList)c;
// Get collect the values that have been currently selected
Object[] values = list.getSelectedValues();
StringBuffer buff = new StringBuffer();
for (int i = 0; i < values.length; i++) {
Object val = values;
buff.append(val == null ? "" : val.toString());
if (i != values.length - 1) {
buff.append("\n");
return new StringSelection(buff.toString()); // Return as a string
My Requirement:- So here we are doing
protected Transferable createTransferable(JComponent c) {
JXTable table = (JXTable)c;
int row = table.getSelectedRow();
int col= table.getSelectedColumn();
*// Here we get the absolute path of file. i.e C:\Ashish.txt from   Table's selected cell*
Object value=table.getValueAt(row,col);
*// Here we access that file with location*
File file = new File(value);
*// And now i want to transfer that file as a Transferable object*
return ( file ); // Need to return a file(NOT FILE NAME)
In above procedure i would not able to return a file as a object. Please suggest me. Thanks in advance.
Ashish Pancholi

Thank you very much for your valuable advice.I am in need of one more help.......
As i am on task to do resize window of my JAVA API and drags a file from JXTable and drop it to my desktop OR any where in file system then it should be copy their.
But i am getting to difficulties
*1> As i start a file to drag and cross the edge of my JAVA API..cursor of mouse is showing be Symbol of DefaultCopyONDrop (/) something like that.*
*2> I sincerely need a absolute path of location where i have released my mouse to drop so that i can copy that file their.*
So can you please help me know the solution of these two difficulties. I want file system to accept my file which i am dragging and need location to copy file. Once again thanks in advance.

Similar Messages

  • My mp3's were in a seperate directory.  Now, all are transferred to iTunes Media.  How can I return the files to the directory??

    I had all my mp3's in a directory on a secondary drive on my desktop computer.  I used Winamp as my music organizer and all went without any changes.  I could add information through the Winamp system, make playlists, and all was well.  Now, I've added an iPod that I was discarded from my son, but am finding that many of the music files have been moved to the iTunes Media directory and taken off the secondary drive complately.  And, they're all organized in seperate 'album' directories.
    I've been going directory by directory to copy and paste the music files to the original directory, but there's more than 5,000 files and it's frustrating (an understatment!!!).
    Is there a better way to put the files back into the original folder?

    The files that weren't inside the media folder on the original machine need to be copied over to exactly the same paths as they had on the source machine. See this thread for an ongoing discussion of a similar problem. See also this post on migrating the iTunes library.
    tt2

  • How can servlet return data as download file from browser ? !!! URGENT !!!

    My servlet query data from database and would like to return the data as text file.
    How can I return data to the browser as user click a file to download ?
    How can I set the file name ? (default name is the servlet name that I don't want it to be)
    Which content type should I return to browser to prevent browser to display data immediately but save instead ?
    Thank you very much !

    I am having the same issue. Did you ever discover a way to change the "file name" in the browser. I've tried changing numerous HTTP header fields, to no avail.
    Marc

  • I have sent a file to the trash bin. When I come to empty the trash bin everything goes out except this one particular file and I get a note saying the file is 'in use' but it is not. How can I delete this file from trash?

    I have a Macbook Pro with OS X Lion 10.7.2. I have sent a work file to the trash bin along with many other files. When I empty the trash this one particular file remains and I get a message that this file is still in use. I have tried returning the file to my documents, opening it, closing it and then sending it to trash and again I try to empty trash but the same message comes up - Q - How can I trash this file permanently?

    First just try logging out and back in.  Whatever is holding on to it may not be running after the logout thus freeing it so you can trash it after logging back in.
    You might also try Trash It!
    Lastly, look at the following for suggestions:
    The X Lab: Solving Trash Problems

  • How can I assign image file name from Main() class

    I am trying to create library class which will be accessed and used by different applications (with different image files to be assigned). So, what image file to call should be determined by and in the Main class.
    Here is the Main class
    import org.me.lib.MyJNIWindowClass;
    public class Main {
    public Main() {
    public static void main(String[] args) {
    MyJNIWindowClass mw = new MyJNIWindowClass();
    mw.s = "clock.gif";
    And here is the library class
    package org.me.lib;
    public class MyJNIWindowClass {
    public String s;
    ImageIcon image = new ImageIcon("C:/Documents and Settings/Administrator/Desktop/" + s);
    public MyJNIWindowClass() {
    JLabel jl = new JLabel(image);
    JFrame jf = new JFrame();
    jf.add(jl);
    jf.setVisible(true);
    jf.pack();
    I do understand that when I am making reference from main() method to MyJNIWindowClass() s first initialized to null and that is why clock could not be seen but how can I assign image file name from Main() class for library class without creating reference to Main() from MyJNIWindowClass()? As I said, I want this library class being accessed from different applications (means different Main() classes).
    Thank you.

    Your problem is one of timing. Consider this simple example.
    public class Example {
        public String s;
        private String message = "Hello, " + s;
        public String toString() {
            return message;
        public static void main(String[] args) {
            Example ex = new Example();
            ex.s = "world";
            System.out.println(ex.toString());
    }When this code is executed, the following happens in order:
    1. new Example() is executed, causing an object to constructed. In particular:
    2. field s is given value null (since no value is explicitly assigned.
    3. field message is given value "Hello, null"
    4. Back in method main, field s is now given value "world", but that
    doesn't change message.
    5. Finally, "Hello, null" is output.
    The following fixes the above example:
    public class Example {
        private String message;
        public Example(String name) {
            message = "Hello, " + name;
        public String toString() {
            return message;
        public static void main(String[] args) {
            Example ex = new Example("world");
            System.out.println(ex.toString());
    }

  • How can i wrote configuration file in Log4j

    iam new log4j .i have seen one small programme in log4j examples folder ..i e. shown below
    Sort.java
    =====
    package examples;
    import org.apache.log4j.PropertyConfigurator;
    import org.apache.log4j.Logger;
    import org.apache.log4j.Priority;
    Example code for log4j to viewed in conjunction with the {@link
    examples.SortAlgo SortAlgo} class.
    <p>This program expects a configuration file name as its first
    argument, and the size of the array to sort as the second and last
    argument. See its <b>source
    code</b> for more details.
    <p>Play around with different values in the configuration file and
    watch the changing behavior.
    <p>Example configuration files can be found in <a
    href="doc-files/sort1.properties">sort1.properties</a>, <a
    href="doc-files/sort2.properties">sort2.properties</a>, <a
    href="doc-files/sort3.properties">sort3.properties</a> and <a
    href="doc-files/sort4.properties">sort4.properties</a> are supplied with the
    package.
    <p>If you are also interested in logging performance, then have
    look at the {@link org.apache.log4j.performance.Logging} class.
    @author Ceki G&uuml;lc&uuml; */
    public class Sort {
    static Logger logger = Logger.getLogger(Sort.class.getName());
    public static void main(String[] args) {
         if(args.length != 2) {
              usage("Incorrect number of parameters.");
         int arraySize = -1;
    try {
              arraySize = Integer.valueOf(args[1]).intValue();
              if(arraySize <= 0)
                   usage("Negative array size.");
    catch(java.lang.NumberFormatException e) {
    usage("Could not number format ["+args[1]+"].");
    PropertyConfigurator.configure(args[0]);
    int[] intArray = new int[arraySize];
    logger.info("Populating an array of " + arraySize + " elements in" +" reverse order.");
    for(int i = arraySize -1 ; i >= 0; i--) {
              intArray[i] = arraySize - i - 1;
    SortAlgo sa1 = new SortAlgo(intArray);
    sa1.bubbleSort();
    sa1.dump();
    // We intentionally initilize sa2 with null.
    SortAlgo sa2 = new SortAlgo(null);
    logger.info("The next log statement should be an error message.");
    sa2.dump();
    logger.info("Exiting main method.");
    static void usage(String errMsg) {
         System.err.println(errMsg);
         System.err.println("\nUsage: java org.apache.examples.Sort " + "configFile ARRAY_SIZE\n"+
    "where configFile is a configuration file\n"+" ARRAY_SIZE is a positive integer.\n");
    System.exit(1);
    and
    SortAlgo.java
    ==========
    package examples;
    import org.apache.log4j.Category;
    import org.apache.log4j.NDC;
    Example code for log4j to viewed in conjunction with the {@link
    examples.Sort Sort} class.
    <p>SortAlgo uses the bubble sort algorithm to sort an integer
    array. See also its <b>source
    code</b>.
    @author Ceki G&uuml;lc&uuml; */
    public class SortAlgo {
    final static String className = SortAlgo.class.getName();
    final static Category CAT = Category.getInstance(className);
    final static Category OUTER = Category.getInstance(className + ".OUTER");
    final static Category INNER = Category.getInstance(className + ".INNER");
    final static Category DUMP = Category.getInstance(className + ".DUMP");
    final static Category SWAP = Category.getInstance(className + ".SWAP");
    int[] intArray;
    SortAlgo(int[] intArray) {
    this.intArray = intArray;
    void bubbleSort() {
    CAT.info( "Entered the sort method.");
    for(int i = intArray.length -1; i >= 0 ; i--) {
    NDC.push("i=" + i);
    OUTER.debug("in outer loop.");
    for(int j = 0; j < i; j++) {
         NDC.push("j=" + j);
         // It is poor practice to ship code with log staments in tight loops.
         // We do it anyway in this example.
         INNER.debug( "in inner loop.");
    if(intArray[j] > intArray[j+1])
         swap(j, j+1);
         NDC.pop();
    NDC.pop();
    void dump() {   
    if(! (this.intArray instanceof int[])) {
    DUMP.error("Tried to dump an uninitialized array.");
    return;
    DUMP.info("Dump of integer array:");
    for(int i = 0; i < this.intArray.length; i++) {
    DUMP.info("Element [" + i + "]=" + this.intArray);
    void swap(int l, int r) {
    // It is poor practice to ship code with log staments in tight
    // loops or code called potentially millions of times.
    SWAP.debug( "Swapping intArray["+l+"]=" + intArray[l] +
         " and intArray["+r+"]=" + intArray[r]);
    int temp = this.intArray[l];
    this.intArray[l] = this.intArray[r];
    this.intArray[r] = temp;
    This program expects a configuration file name as its first
    argument, and the size of the array to sort as the second and last
    argument. See its <b>source
    code</b> for more details.
    please help me how can write that configuration file
    thanks

    Hi bala,
    check that log4j manual I pointed to in yer previous thread.
    This is a pot-boiler config file... Copy it into some file say "props.conf" and use it.
    # Set root logger level to DEBUG and its only appender to A1.
    log4j.rootLogger=DEBUG, A1
    # A1 is set to be a ConsoleAppender.
    log4j.appender.A1=org.apache.log4j.ConsoleAppender
    # A1 uses PatternLayout.
    log4j.appender.A1.layout=org.apache.log4j.PatternLayout
    log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%nCheers,

  • How can i traverse between files in a directory

    how can i traverse between files in a directory. I ahve seen in the site that isFile can be used to switch from one file to other but i didn't found such method. I am working in Eclipse. I would be thankful if u send me the solution.I mean the way to traverse

    listFiles() returns all the files in a directory. You can check if it is a file and read it. Read the API docs.
    If you have specific problem with your code, post the code and the problem description.

  • How can I associat ".swf" files with flashlite 2.1

    How can I associate ".swf" files with flashlite 2.1? When I
    install flash lite 2.0,it can do ---- click .swf files system can
    autoly use flashlite to play.But now I install flashlite 2.1,it
    lost this ability return as "unknow files formate".
    Now,how can I reassociate ".swf" with flashlite 2.1?
    first: I must use flashlite 2.1.
    second:I must click .swf file directly.
    I know another way to open :open the player and then find the
    .swf,and open it. But ,unfortunately,I can not use this way to
    open.Now I will be looking for another way.

    unfortunately, the 2.1 developer edition you have installed
    has not overwritten the original version integrated into the
    symbian OS by the manufacturer. This means that the only way to
    open the 2.1 files is to open the 2.1 player from your apps menuu,
    and click on the swf file. You will only get direct access if the
    updated player is in a firmware update for you handset.
    Matt
    http://www.outside-media.co.uk/blog

  • The product I bought its not working as i expected, it doesn´t translate the exact information from pdf to excel, how can you help me or how can you return my money back....

    how can you help me

    What about adobé export PDF. ?
    Enviado desde mi iPhone
    El 07/05/2014, a las 23:00, Claudio González <[email protected]> escribió:
    The product I bought its not working as i expected, it doesn´t translate the exact information from pdf to excel, how can you help me or how can you return my money back....
    created by Claudio González in Adobe Reader - View the full discussion
    If you bought Reader, you were swindled, because it's a free program. And it has never been able of converting PDF files to any other format.
    Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at https://forums.adobe.com/message/6363992#6363992
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page:
    To unsubscribe from this thread, please visit the message page at . In the Actions box on the right, click the Stop Email Notifications link.
    Start a new discussion in Adobe Reader by email or at Adobe Community
    For more information about maintaining your forum email notifications please go to http://forums.adobe.com/thread/416458?tstart=0.

  • How can i find the file to which Session Manager has saved my session ?

    How can I find the file to which Session Manager has saved my session ?
    == This happened ==
    Every time Firefox opened
    == User Agent ==
    Opera/9.80 (Windows NT 6.0; U; en) Presto/2.5.24 Version/10.53

    From
    http://support.apple.com/en-us/HT4946
    Where your backups are stored
    The folder where your backup data is stored depends on your computer's operating system. Make sure the backup folder is included in your data-backup routine. iTunes places the backup files in these places:
        Mac: ~/Library/Application Support/MobileSync/Backup/
        The "~" represents your Home folder. If you don't see Library in your Home folder, hold Option and click the Go menu.
        Windows Vista, Windows 7, and Windows 8: \Users\(username)\AppData\Roaming\Apple Computer\MobileSync\Backup\
        To quickly access the AppData folder, click Start. In the search bar, type %appdata%, then press Return.
        Windows XP: \Documents and Settings\(username)\Application Data\Apple Computer\MobileSync\Backup\
        To quickly access the Application Data folder, click Start, then choose Run. In the search bar, type %appdata%, then click OK.
    See here for how to backup
    Back up and restore your iPhone, iPad, or iPod touch using iCloud or iTunes - Apple Support

  • How can I return back to OSx after installing Lion?

    I'm disappointed. After installing Lion, everything is slower. The best thing I had last year was my new MacBook Pro, because everything was fast.. (sleep, opening programs, multitasking...etc) Now, everything takes forever. How can I return back to OSx?

    Downgrade Lion to Snow Leopard
    1.  Boot from your Snow Leopard Installer Disc. After the installer loads select your language and click on the Continue button.  When the menu bar appears select Disk Utility from the Utilities menu.
    2. After DU loads select your hard drive (this is the entry with the mfgr.'s ID and size) from the left side list. Note the SMART status of the drive in DU's status area.  If it does not say "Verified" then the drive is failing or has failed and will need replacing.  SMART info will not be reported  on external drives. Otherwise, click on the Partition tab in the DU main window.
    3. Under the Volume Scheme heading set the number of partitions from the drop down menu to one. Set the format type to Mac OS Extended (Journaled.) Click on the Options button, set the partition scheme to GUID then click on the OK button. Click on the Partition button and wait until the process has completed.
    4. Quit DU and return to the installer. Install Snow Leopard.
    This will erase the whole drive so be sure to backup your files if you don't have a backup already. If you have performed a TM backup using Lion be aware that you cannot restore from that backup in Snow Leopard. I suggest you make a separate backup using Carbon Copy Cloner 3.4.1.

  • I am college student and my professors require we use Turnitin however Turnitin does not support Firefox 4 how can I get it to work with Firefox 4 or how can I return to Firefox 3

    Turnitin will not work with firefox 4 how can I return to firefox 3 or how can I get firefox 4 and Turnitin in sync

    The Turnitin system requirements on mention Firefox 3. If it does not support Firefox 4 you can downgrade to Firefox 3.6
    To downgrade to Firefox 3.6 first uninstall Firefox 4, but do not select the option to "Remove my Firefox personal data". If you select that option it will delete your bookmarks, passwords and other user data.
    You can then install the latest version of Firefox 3.6 available from http://www.mozilla.com/en-US/firefox/all-older.html - it will automatically use your current bookmarks, passwords etc.
    To avoid possible problems with downgrading, I recommend going to your profile folder and deleting the following files if they exist - extensions.cache, extensions.rdf, extensions.ini, extensions.sqlite and localstore.rdf. Deleting these files will force Firefox to rebuild the list of installed extensions, checking their compatibility, and reset toolbar customizations.
    For details of how to find your profile folder see https://support.mozilla.com/kb/Profiles

  • I just upgraded on May 11 and find I cannot open a fold for bookmarks. I research and bookmarks are my lively hood. How can I return the bookmark functionality?

    MS 7 and long time user of Firefox so this is the recent upgrade of May 11. Unlike the prior bookmark functionality, I cannot indicate I want to bookmark a link and designate a new folder for a new topic in two to three clicks. This is critical to what I do for a living. How can I return the prior format and be sure bookmarks are backed up automatically. Does going back to the older and more functional tool bar restore this? And why does clicking the bookmarks toolbar show getting started, most visited and the printer icon? Getting started takes one to a new user set of instructions. But there are no functional operations in the tool bar? I am not going to go thru a lot of commands, this should be a automatic as before.

    '' the bookmark facility is not functional in 29 ... Bookmark puts all bookmarks there into "recently bookmarked" ''
    It does not.
    It works much the same as the old system does. Or at least it should do and does do for me.
    * Carefully reads the following article so you are certain what should be happening '''[[How to use bookmarks to save and organize your favorite websites ]]'''
    # From an unbookmarked page click the bookmarks star.
    #* That results in the bookmark being added, and yes initially it is just as an unsorted bookmark. (No doubt that is where most people put most bookmarks)
    # IMPORTANT click the star a second time. (But not so rapidly it counts as a doubleclick)
    #* You now have the options you had in the old version of Firefox <br /> Create new folders <br /> Save to a recently used folder <br /> Show all bookmark folders - and expand nested folders
    If your bookmarks are not working possibly the file is corrupted in which case see
    * http://kb.mozillazine.org/Bookmarks_history_and_toolbar_buttons_not_working_-_Firefox#Damaged_Places_database
    I am hoping it is just that you are doubleclicking the star too quickly.

  • Hi, how can i return back safari default search engine?

    How can I return back safari default search engine? It has been changed after trying to download adobe flash player.

    You may have installed one or more of the common types of ad-injection malware. Follow the instructions on this Apple Support page to remove it. It's been reported that some variants of the "VSearch" malware block access to the page. If that happens, start in safe mode by holding down the shift key at the startup chime, then try again.
    Back up all data before making any changes.
    One of the steps in the article is to remove malicious Safari extensions. Do the equivalent in the Chrome and Firefox browsers, if you use either of those. If Safari crashes on launch, skip that step and come back to it after you've done everything else.
    If you don't find any of the files or extensions listed, or if removing them doesn't stop the ad injection, ask for further instructions.
    Make sure you don't repeat the mistake that led you to install the malware. It may have come from an Internet cesspit such as "Softonic" or "CNET Download." Never visit either of those sites again. You might also have downloaded it from an ad in a page on some other site. The ad would probably have included a large green button labeled "Download" or "Download Now" in white letters. The button is designed to confuse people who intend to download something else on the same page. If you ever download a file that isn't obviously what you expected, delete it immediately.
    Malware is also found on websites that traffic in pirated content such as video. If you, or anyone else who uses the computer, visit such sites and follow prompts to install software, you can expect more of the same, and worse, to follow. Never install any software that you downloaded from a bittorrent, or that was downloaded by someone else from an unknown source.
    In the Security & Privacy pane of System Preferences, select the General tab. The radio button marked Anywhere  should not be selected. If it is, click the lock icon to unlock the settings, then select one of the other buttons. After that, don't ignore a warning that you are about to run or install an application from an unknown developer.
    Still in System Preferences, open the App Store or Software Update pane and check the box marked
              Install system data files and security updates (OS X 10.10 or later)
    or
              Download updates automatically (OS X 10.9 or earlier)
    if it's not already checked.

  • How can I return in a native method a Java type?

    Hi,
    i want to return in the native methode ja Java type java.awt.Dimension!
    How can I do this?
    Java code:--------------------------------------------------------------------------------
    public native java.awt.Dimension getSize()
    generating the JNI header file
    JNI header code:--------------------------------------------------------------------------------
    JNIEXPORT jobject JNICALL Java_Video_getSize(JNIEnv *, jobject)
    my c function looks like this
    code:--------------------------------------------------------------------------------
    JNIEXPORT jobject JNICALL Java_Video_getSize(JNIEnv *env, jobject obj)
    return ???????
    how can I return in C an object like jawa.awt.Dimension?
    Thx
    Ronny

    Here is my 2 cents for a way we pass data between Java and C via the Java Native Interface. This excerpt is an example of passing an int value through a locally created Integer wrapper class, which must be adapted for local use. Note that because of the wrapper, return values are not needed.
    1. Create the Java class file.
    * This class encapsulates a Java <CODE>int</CODE> primitive.
    * This class was created to allow programmers to change
    * the value of an existing integer object without being
    * forced to create a new object (as is the case with the
    * Java Integer object).
    public class LocalInteger
         private int     value;
         * Creates a LocalInteger object and initializes
         * it to <I>0</I> (the default in Java).
         public LocalInteger ()
              super ();
         * Creates a LocalInteger object and initializes
         * it using the given <I>int</I> value.
         * @param i Integer value to use in initializing
         * the object.
         public LocalInteger (int i)
              super ();
              value = i;
         * Gets the value of the object.
         * @return The value of the object.
         public int getValue ()
              return (value);
    2. Create the jni header file.
    DLL_EXTERN void jni_GetValue_from_LocalInteger(int* LocalInteger, JNIEnv *env, jobject thisLocalInteger);
    3. Create the C file.
    /*start of jni header****************************************
    *NAME/TITLE:       jni_GetValue_from_LocalInteger
    *DESCRIPTION:      This routine copies the integer value
    * from the Java LocalInteger object to the
    * C 'int' variable.
    *CALLING SEQUENCE: jni_GetValue_from_LocalInteger (LocalInteger,
    * env,
    * thisLocalInteger)
    *PARAMETERS:
    * Type Name I/O Description
    * int * LocalInteger I/O C variable
    * JNIEnv * env I JNIEnv pointer
    * jobject thisLocalInteger I Java object
    *RETURN:           N/A
    **end of header*********************************************/
    /* ********************** BEGIN CODE ********************** */
    DLL_EXPORT
    void jni_GetValue_from_LocalInteger(int* LocalInteger, JNIEnv *env, jobject thisLocalInteger)
         LocalInteger = (int) (env)->GetIntField(env, thisLocalInteger, LocalInteger_Value);

Maybe you are looking for