Page 1 of 2 12 LastLast
Results 1 to 20 of 28

Thread: Plz help

  1. #1
    Join Date
    Oct 2010
    Posts
    13
    Rep Power
    0

    Default Plz help

    I want to know how to write data on DVD using JAVA..pLz reply ...:p;)

  2. #2
    m00nchile is offline Senior Member
    Join Date
    Feb 2010
    Location
    Ljubljana, Slovenia
    Posts
    470
    Rep Power
    5

    Default

    I want to know how to hack a bank and get a lot of money, PLZ HELP.
    Ever seen a dog chase its tail? Now that's an infinite loop.

  3. #3
    Join Date
    Oct 2010
    Posts
    13
    Rep Power
    0

    Default

    what is this Sir j....i need help save me

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Means that you should clever on your question. Ask it with more details, and you must show some effort too. Did you try anything to get done that yourself?

  5. #5
    Join Date
    Oct 2010
    Posts
    13
    Rep Power
    0

    Default YA i

    Hai..
    Ya i tried to write the data to DVD drive ...but its a dummy....i just copied from source to DVD drive..but i m not getting how to burn that DVD...so plz help how to burn the DVD..

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  7. #7
    Join Date
    Oct 2010
    Posts
    13
    Rep Power
    0

    Default

    k..i send you my code...

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  9. #9
    Join Date
    Oct 2010
    Posts
    13
    Rep Power
    0

    Default

    Java Code:
    import java.io.*;
    import javax.swing.*;
     
    public class MovingFile{
     
      public static void main(String[] args) throws IOException{
     
        int a = 0;
     
       BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        System.out.print("Enter the file or directory name that has to be moved : ");
     
       String src = in.readLine();
     
        if(src.equals("")){
     
         System.out.println("Invalid directory or file name.");
     
          System.exit(0);
     
       }
     
       File source = new File(src);
     
        if(!source.exists()){
     
         System.out.println("File or directory does not exist.");
     
          System.exit(0);
     
       }
        
    System.out.print("Enter the complete path where file or directory 
                           has to be moved: ");
     
        String dest = in.readLine();
     
        if(dest.equals("")){
     
          System.out.println("Invalid directory or file name.");
    
            System.exit(0);
     
       }
      
      File destination = new File(dest);
    
    
          if(!destination.exists()){
     
          System.out.print("Mentioned directory does not exist.
                       \nDo you want to create a new directory(Y/N)? ");
     
          String chk = in.readLine();
     
    
          if(chk.equals("Y") || chk.equals("y")){
     
           destination.mkdir();
       
         copyDirectory(source, destination);
     
           a = 1;
      
        }
      
        else if(chk.equals("N") || chk.equals("n")){
     
           System.exit(0);
      
        }
         
     else{
      
          System.out.println("Invalid Entry!");
     
           System.exit(0);
      
        }
        
    }
        
    else{
     
          int num = JOptionPane.showConfirmDialog(null, "Given file or folder name already exists. \nDo you want to replace now?");
     
         if(num == 0){
     
            copyDirectorys(source, destination);
      
          a = 1;
        
      }
       
     }
      
      if(a == 1){
     
          System.out.println("File or directory moved successfully.");
     
         if(!delete(source)){
     
           throw new IOException("Unable to delete original folder");
     
         }
     
       }
        else if(a == 0){
      
        System.exit(0);
       
     }
     
     }
    
     
      public static void copyDirectorys(File sourceDir, File destDir)
                    throws IOException{
     
       if(!destDir.exists()){
     
          destDir.mkdir();
     
       }
      
      File[] children = sourceDir.listFiles();
    
          for(File sourceChild : children){
     
         String name = sourceChild.getName();
     
          File destChild = new File(destDir, name);
    
            if(sourceChild.isDirectory()){
     
           copyDirectory(sourceChild, destChild);
     
          }
         
     else{
      
          copyFiles(sourceChild, destChild);
     
         }
       
     }
     
     }
     
     
      public static void copyFiles(File source, File dest) throws IOException{
     
       if(!dest.exists()){
      
        dest.createNewFile();
     
        }
       
     InputStream in = null;
     
        OutputStream out = null;
     
        try{
     
         in = new FileInputStream(source);
    
            out = new FileOutputStream(dest);
     
          byte[] buf = new byte[1024];
    
            int len;
     
          while((len = in.read(buf)) > 0){
     
            out.write(buf, 0, len);
    
                }
       
         }
      
      finally{
     
         in.close();
     
               out.close();
     
            }
     
      }
    
     
     public static boolean delete(File resource) throws IOException{ 
    
          if(resource.isDirectory()){
     
          File[] childFiles = resource.listFiles();
     
          for(File child : childFiles){
      
          delete(child);
       
       }
       
     }
        
    return resource.delete();
     
      }
     
    }
    Last edited by Eranga; 10-13-2010 at 10:05 AM. Reason: code tags added

  10. #10
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    See how nicer that if you use code tags.

    Regarding your question, in your code I can see that you've just manipulate files. Nothing done related with DVD burning. Am I correct?

  11. #11
    Join Date
    Oct 2010
    Posts
    13
    Rep Power
    0

    Default

    ya correct...i m just manipulation ...how to burn in this section i m confused..how to start the coding..from where i should start..shall i detect the DVD-ROM or else..wht is the soln????

  12. #12
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Say you've a file, which contain some data, may be an image for instance. So you want to burn them into a DVD, which is in place inside the DVD R/W, a hardware part of the PC. You have to pass image into the DVD R/W, and you must convert it into an understandable format. Once you submit to the device, you've to instruct to start it's process. Is that clear?

    If so think how we can do that in Java. Send your thoughts over here.

  13. #13
    Join Date
    Oct 2010
    Posts
    13
    Rep Power
    0

    Default

    exactly i want this..u give me some instruction how to do this...i can do...

  14. #14
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Then start from the hardware access. Read about how to access device in Java. It's worth addressing doing anything else.

  15. #15
    Join Date
    Oct 2010
    Posts
    13
    Rep Power
    0

    Default

    k..thanks..i can do....

  16. #16
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  17. #17
    Join Date
    Oct 2010
    Posts
    13
    Rep Power
    0

    Default

    ya only in c and i m currently working on delphi..

  18. #18
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  19. #19
    Join Date
    Oct 2010
    Posts
    13
    Rep Power
    0

    Default

    i have no idea in c

  20. #20
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •