Problem while writing image to disk..............

AOA
in my application i scan an image and then try to write it to c:\image folder in windows then it gives following exception.
java.io.FileNotFoundexception: c:\image (Access is denied)
i have checked the security and permissions for C.
they allow the user to write but problem is still there.
what may b the reason

If I use the following code:
try {
    FileWriter out = new FileWriter("C:/DRIVERS");
} catch(IOException ioe) {
    ioe.printStackTrace();
I get
java.io.FileNotFoundException: C:\DRIVERS (Access is denied)======================================================
The above is have relative path in
FileWriter out = new FileWriter("C:/DRIVERS");instated of giving relative("C:/DRIVERS") path you just give the absolute
path.
FileWriter out = new FileWriter("C:/DRIVERS/filename/yourscanimage");

Similar Messages

  • Problems while accessing images outside the web document-root folder

    Our application runs on Oracle application server on Linux. Facing problems while accessing images outside the web document-root folder. This works with changes in global-web-application.xml by including the <virtual-directory> tag. The same change does not work when done on Linux machine. It is unable to find the image. Please help in resolving this issue.
    </locale-encoding-mapping>
    </locale-encoding-mapping-list>
    </web-app>
    <virtual-directory virtual-path="/img" real-path="/home/eposuat/" />
    </orion-web-app>
    Code in the jsp:
    <img width=700 height=700 src="/img/3.tif"></img>
    <img width=700 height=700 src="/img/WB.gif"></img>

    This is one of the least satisfactory aspects of site management in Dreamweaver, and several developers, including myself, have been pressuring the Dreamweaver team for some years to improve this. Who knows? They might eventually take notice.
    The only way to do this at the moment is to create two site definitions, one nested inside the other. Set up the site definition normally based on htdocs as your site root. Then create a new site definition based on site. Dreamweaver will nag you that it can cause problems, but it won't actually stop you from doing it. The only potential problem is with site synchronization.
    The problem with using site as the only basis for your site definition is that Dreamweaver automatically puts things like the Connections, Scripts, and other folders in the site root. So, everything ends up at the wrong level of the site hierarchy. Quite frankly, the whole thing is a bit of a pain. Dynamic site development was added to Dreamweaver only in version 6 (Dreamweaver MX), and no one had really thought through the need to store files outside the site root.

  • Problem while writing data on xls file using jxl API

    Hi,
    I am getting problem while writing data on excel file using jxl api.
    When i write data on file and all handles associated to the file are closed, file size increases but when i open the file nothing is written in it and when file is closed manually from excel window, file size decreased to its original that was before writing data.
    here is code:
              FileOutputStream os = new FileOutputStream(this.dirPath + this.fileName, true);
              WritableWorkbook this.workbook = Workbook.createWorkbook(os);
    after writing data following handler are closed:
    this.os.flush();
                        this.workbook.write();
                        this.workbook.close();
                        this.os.close();
                        this.os = null;
    can any body help me.
    Thanks in advance

    Err, I did help you. I did understand your problem; and I solved it for you. What was missing was that you apparently made no effort to understand what you were being told. Or even consider it. You just argued about it, as though you were the one with the solution, instead of the one whose code didn't work.
    And the other thing that was missing was the part where you said 'thank you' to me for solving your problem. Somewhat more appropriate than biting the hand that fed you, frankly. I do this for nothing, on my own gas, and it's extremely irritating when people keep asking about problems I have already solved for them. I am entitled to discourage that. It's part of making them more efficient actually.
    But it happens often enough that it also makes me think I'm just wasting my time. Probably I am.

  • Problem in writing image

    Hi,
    I have a problem in writing png.
    Here's my code:
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.image.BufferedImage;
    import java.awt.image.RenderedImage;
    import java.io.File;
    import java.io.IOException;
    import javax.imageio.ImageIO;
    import javax.swing.ImageIcon;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    public class ProvaImg extends JPanel{
         private static JFrame frame;
          * @param args
         public static void main(String[] args) {
              frame = new JFrame ();
              frame.setSize(100,100);
              ProvaImg pi=new ProvaImg();
              frame.add(pi);
              frame.setVisible(true);
              //PROBLEM HERE
              frame.setVisible(false);
         public ProvaImg(){
              super();
             // Returns a generated image.
             public void paintComponent(Graphics g) {
                 int width = 100;
                 int height = 100;
                 // Create a buffered image in which to draw
                 BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
                 Graphics2D g2d=(Graphics2D)g;
                 // Create a graphics contents on the buffered image
                  g2d = bufferedImage.createGraphics();
                 // Draw graphics
                 g2d.setColor(Color.white);
                 g2d.fillRect(0, 0, width, height);
                 g2d.setColor(Color.black);
                 g2d.fillOval(0, 0, width, height);
                 // Graphics context no longer needed so dispose it
                 g2d.dispose();
                  try {
                      // Save as PNG
                      File file = new File("newimage.png");
                      System.out.println("png");
                      ImageIO.write(bufferedImage, "png", file);
                  } catch (IOException e) {
         }If I comment line after
    //PROBLEM HERE
    it works, otherwise no.
    Is there a possibility to close panel when image has been written?
    Thanks in advance
    Bye

    No,
    I try to explain better:
    In my real application (not this simple example) I compose an image by the union of many little gifs. Then I have to save the result in a unique image. It's for this that I've overridden paintComponent(), so , after having painted all gifs, I save composite image to a png one.
    This function is activated from a main application, and I don't want to show too much to user, so I try to make this by using a popup frame that disappear quickly.
    I hope to having been as clear as possible.
    I hope to have chosen the best solution too
    Bye and thanks
    Edited by: giuseppe_italiano on Nov 21, 2007 3:35 AM

  • Problems while writing to file

    Hi,
    I'm trying to query my test database (mysql) and to write these results to a file, I manage to get the results out of the database, but when I try to write for instance an int to a file, the file replaces the int by a square. What can be wrong?? The file is created successfully and I've writen the int to the standard out before writing it to the file; in the standard out the int is correct.
    code:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.sql.*;
    public class getData extends HttpServlet {
    FileWriter fw;
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    response.setContentType("text/html");
    java.io.PrintWriter out = response.getWriter();
    try {
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    } catch(Exception e){
    System.err.println("Database driverclass not found");
    Connection conn;
         //insert values into DB
    try {
         conn = DriverManager.getConnection("jdbc:mysql://localhost/test?user=admin12&password=adm12");
    Statement stmt = conn.createStatement();
    String slq = "Select * from feedback";
    ResultSet rs = stmt.executeQuery(slq);
    if (rs==null){System.out.println("nOT OK");}
    else{
    try{
    File f = new File("D:\\mysql\\Data.txt");
    fw = new FileWriter(f);
    while(rs.next())
    writeToFile(rs.getString(1));
    writeToFile(rs.getString(2));
    writeToFile(rs.getInt(3));
    writeToFile(rs.getInt(4));
    writeToFile(rs.getString(5));
    writeToFile(rs.getInt(6));
    catch(IOException e)
    System.out.println("Error occured while writing to file");
    stmt.close();
         conn.close();
    } catch(SQLException sqle){
    System.err.println("A SQL error has occured: " + sqle.getMessage());          
    /* output your page here*/
    out.println("<html>");
    out.println("<head>");
    out.println("<title>getDataServlet</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("<h2>Data recovered</h2>");
    out.println("</body>");
    out.println("</html>");
    out.close();
    fw.flush();
    fw.close();
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    processRequest(request, response);
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    processRequest(request, response);
    /** Returns a short description of the servlet.
    public String getServletInfo() {
    return "Short description";
    private void writeToFile(int i)
    try{
    System.out.println("test: "+i);
    fw.write(i);
    fw.write(";");
    }catch(IOException e1)
    private void writeToFile(String str)
    try{
    if (str!=null&&(str.equals("null")==false)){
    fw.write(str);
    fw.write(";");
    }catch(IOException e2)

    I would imagine that FileWriter is writing the byte value to the file. Just change your SQL get to this writeToFile(rs.getString(6)); and write it as a String instead of an int.
    DesQuite

  • Problem while writing to fixed length flat file from xml

    Hi,
    I have a problem in writing data into a flat file of fixed length...
    My input is a xml file and i want the output as a flat file. I am successful in converting the xml into flat file... But the main problem is, i am unable to insert spaces in between my fields in the flat file.
    The data in the flat file comes without spaces... Any suggestions on writing the schema...
    Regards
    Surya.

    Have a look at this doc
    http://otndnld.oracle.co.jp/document/products/as10g/101310/doc_cd/integrate.1013/b28994/nfb.htm#BGBBAJFD
    your element should be something like this, it pads with a space using the paddedBy expression
    <xsd:element name="C1" type="xsd:string" nxsd:style="fixedLength" nxsd:length="4" nxsd:paddedBy=" " nxsd:padStyle="tail" />if having trouble post what you want the file to look like, and the xsd you are using.
    cheers
    James

  • Problem while uploading Image to DataBase

    Hi ,
    i m getting exception while executing code below,
    is there anything to configure the data base before uploading images onto the database....
    Connection con=null;
    try{
    Class.forName("youroracledriver").newInstance();
    con = DriverManager.getConnection("url");
    PreparedStatement ps = con.prepareStatement("INSERT INTO pictures VALUES(?,?)");
    File file=new File("F:/servletworkspace/insertingimage/bb.jpg");
    FileInputStream fs = new FileInputStream(file);
    ps.setInt(1,15);
    ps.setBinaryStream(2,fs,(int)file.length());
    int i = ps.executeUpdate();
    if(i!=0){
    out.println("image inserted successfully");
    else{
    out.println("problem in image insertion");
    catch (Exception e){
    System.out.println(e);
    }

    To connect to database if your need to register driver and then make connection. So instead of:
    user8689318 wrote:
    Class.forName("youroracledriver").newInstance();
    con = DriverManager.getConnection("url");you should have (if you are connecting to oracle using oracle jdbc driver):
    DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
    con = DriverManager.getConnection("jdbc:oracle:thin:@<your db listener ip>:<your db listener port>:<your db sid>", "<db user>", "<db user password");
    plus in future if you getting exception, then you should post it as well

  • Problem while loading Image from datat base

    i have sotred iamge as blob in data base while reading from data base and loading i am getting error if image is more than 30 kb
    when i pass bytearrayinputstream to ImageIo.read(bytearrayinputstream ) but problem is not occure if iamge is less thatn 30 kb (approx) why is it so how to store image is data base and read from the data base
    i want both buffered image as well as SWT Image

    {color:#000080}I tried to read your post but it is throwing a NoPunctuationException.
    Would you care to repost with a few commas and full stops to make it readable?
    db{color}

  • Problem saving an image to disk - sometimes its black??

    Hi i'm trying to create a thumbnail of an image and save it to disk using Image and Graphics2D. The problem i'm having is that sometimes when i save the image its blank\black, it seems totally random in doing this i.e. it will work find one time and then not work the next time (i'm actually processing a whole folder of images in my program)
    Image image = new ImageIcon(imgfile).getImage();
    BufferedImage bi = new BufferedImage(100,100,BufferedImage.TYPE_INT_RGB);
    Graphics2D g2d = bi.createGraphics();
    if(image.getWidth(null) > image.getHeight(null)){
    // create landscape image thumbnail     
    image = image.getScaledInstance(133,100,Image.SCALE_DEFAULT);
    // here i'm cropping the image so that its square + focusing the center of the image
    g2d.drawImage(image,                               0,                              0,                              100,                              100,                              15, // start x coordinate                         0, // start y corodinate                         115,// end x corodinate                         100,// end y coordinate                         null);                              
    else...
    If anyone could shed any light on to why this problem is occuring i would be really greatful, its driving me nuts! :P
    btw: if anyone knows of a better way of doing this please let me know to. i'm sure u should b able to scale the image and crop it just using Graphics2D, just dont know how though...
    Many Thanks,
    Tom

    some of the images that i'm processing are dark but there are many others that aren't, all images that are outputed are totally black.
    I'm kind of suspecting that it may be a case of the image isn't being fully loaded when the scale\crop is performed. i have noticed that the larger the file\resolution the more likely it will be draw\saved correctly.,this leads me to beleave that the problem may lie in the loading...
    I have been looking at MediaTracker as that seems to be meant for this sort of situation but all the examples i see involve JFrames\Applets which my program doesn't make use of. Am i right in thinking that MediaTracker requires a java.awt.Component when being created? is there anyway round of this or is there anything else you can think of that i could use to do a similar job?
    Many Thanks, Tom

  • Java.io.FilePermission error while writing file to disk

    Hi All,
    I have done a simple JSP form in which am uploading a file to the server, am using apache commons file upload, in my local system its working fine(windows), but when i uploaded the same to the shared server(Linux), tomcat throwing a exception when java class file trying to write the file to disk, i have given all permissions (read,write,execute) to all users to the target folder("timeSheet_uploadedFiles") where am trying to write the file and tried but no luck still the exception continues, below i copied the exception am getting, somebody please help me.
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    javax.servlet.ServletException: access denied (java.io.FilePermission /var/chroot/home/content/html/timeSheet_uploadedFiles/admin_4_5_CSharp Coding Standards.pdf write)
         org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:545)
         org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:486)
         org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
         org.apache.struts.action.ActionServlet.process(ActionServlet.java:1480)
         org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:524)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         sun.reflect.GeneratedMethodAccessor67.invoke(Unknown Source)
         sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         java.lang.reflect.Method.invoke(Method.java:585)
         org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:239)
         java.security.AccessController.doPrivileged(Native Method)
         javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
         org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:266)
         org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:157)
    root cause
    java.security.AccessControlException: access denied (java.io.FilePermission /var/chroot/home/content/html/timeSheet_uploadedFiles/admin_4_5_CSharp Coding Standards.pdf write)
         java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
         java.security.AccessController.checkPermission(AccessController.java:427)
         java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
         java.lang.SecurityManager.checkWrite(SecurityManager.java:962)
         java.io.FileOutputStream.<init>(FileOutputStream.java:169)
         java.io.FileOutputStream.<init>(FileOutputStream.java:70)
         com.roots.UploadAction.upload(UploadAction.java:72)
         sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         java.lang.reflect.Method.invoke(Method.java:585)
         org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)
         org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:216)
         org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
         org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
         org.apache.struts.action.ActionServlet.process(ActionServlet.java:1480)
         org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:524)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         sun.reflect.GeneratedMethodAccessor67.invoke(Unknown Source)
         sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         java.lang.reflect.Method.invoke(Method.java:585)
         org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:239)
         java.security.AccessController.doPrivileged(Native Method)
         javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
         org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:266)
         org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:157)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.0.27 logs.
    Apache Tomcat/5.0.27Thanks,
    vyrav.

    You have apparently missed setting the write permission to the target directory for the user that Tomcat is running as. Tomcat may be running as a different user than the one you are logged into on the system.
    It may be trying to save to an incorrect location, so double check the directory is what you expect it to be.
    The file may already exist, so it may not be able to over-write the file, so make sure you give the tomcat user the ability to delete and overwrite as well as write - or check if the file exists before writing and warn user if you don't want to give delete permissions.

  • Problem while writing the data (LSMW direct input method for Creating BOM )

    Hi all ,
    I am unable to create a BOM using LSMW standard dirrect input mehtod .
    While i going through the *Read data *  step , it is reading the data but unable to write the data .
    My input text files are correct , Is it a problem with respect to the Logical Path or Logical File ......
    Please let me know the Possibilities of arising this problem .
    Regards,
    Raj

    Hi,
      Check this document:
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/90d90895-68dd-2a10-f096-bf8cf2e2f65b
    cheers
    Aveek

  • Time Stamp problem while writing data into the excel file

    Hii, All
                  I am taking the data from the DAQ card of the TOPSCCC with the 8 ms of scanrate for each channel and there are total 16 no of Analog channels in the Card, now i am acquiring the data from the card, time stamping it and writing it into the excel file, which is tab delimited, now the problem is, the data which are in the excel file have the same timestamp for 4 to 5 continuous records, instead we want each data with the different and continuous time stamp with same difference of time stamp between two records, mean if it is difference of 8 ms then it should be the 8 ms for all, but here it is taking the differnce of 16 ms for two samples and giving same time stamp for four to five records and that shouldn't happen, here i am attaching my vi, drivers for the cards and Excel file with the data, can you please give me any suggestion how to do it?
           Please help me i require this suggestion as early as possible, i am requiring it urgently.
    Thanks in Advance,
    Nishant
    Attachments:
    2026vi.llb ‏319 KB
    2026_ScanMultAD_Demo_time.vi ‏80 KB
    Data.xls ‏357 KB

    Hello Nishant,
    that's what I meant:
    Message Edited by GerdW on 05-16-2006 10:32 AM
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome
    Attachments:
    timestamp-array.png ‏2 KB

  • Problem while writing BDC Code......

    Hi All,
    I am writing a BDC Code to call transaction: PRFI.
    Ones the transaction is run(from GUI directly) for a particular trip number, the status of the trip gets changed to Docs Created. On the other hand while doing the same using the BDC method, the status that is getting generated is: Selection is Running.
    It looks as if the transaction is not getting committed properly.
    I am writing the BDC very correctly and also screen sequences are trapped properly.
    Please help.
    Abhi.
    Edited by: Digvijay Sharma on Jul 29, 2010 12:14 PM

    Hi,
    You saying that all screens and flow logic will be written properly.
    use SHDB for recording that transaction then compare each Dynpro and all the things.
    It will be helpful for you.

  • Problem while writing to file

    I have a value '2222.12' stored in a database table. i fetch this value and write this value to a file but in file the value is '2222,12' instead of '2222.12'. i.e dot is being replaced with a comma automatically, can anyone tell what is the mistake i am making?????
    my code is for writing to file is:
    Sys.UTL_FILE.PUT_LINE (file_handle,my_cursor.amount);

    To answer any question at a minimum you need to post
    4 digit Oracle version (from select * from v$version)
    OS and version
    In this particular case : regional settings when running on Windows
    Apparently you are writing a number and you are relying on implicit conversion to a character string, as put_line writes strings only.
    You may want to use explicit conversion and use to_char(my_cursor.amount,'99999.09')
    Sybrand Bakker
    Senior Oracle DBA
    Edited by: sybrand_b on 21-apr-2010 7:11

  • Problems while writing xml doc to a  file

    Hi all , in my project (of distributed xml databases) i need to write the xml files from the main server to the clients.
    These xml files i had formed by fragmenting one xml doc and i did the fragmentation using ....
    TransformerFactory tf = TransformerFactory.newInstance();
              Transformer transformer = tf.newTransformer();
              transformer.transform(new DOMSource(root),
              new StreamResult(new FileOutputStream(outputFile)));
    Now the problem is that on the client where these fragments reside..i m not able to do the indexing of the document properly ie...
    some extra text nodes with no values are coming in the index...
    i dont know how to deal wid the extra nodes that i m getting after parsing the file and craeting an index for the same..
    may be its coz of the transformer func i m using....don know(???)
    Note : i m fragmenting the xml files into text files using the above function and then sending thm to the client via sockets.
    Also,after fragmenting i am getting sumthng like
    <?xml version="1.0" encoding="UTF-8"?>
    in all the files..is this a source of any problem....
    plz reply soon....

    You have not described how you "index" the files and what you mean by that.
    Are you processing them with SAX or DOM, or one of the variations of those means?
    Is there a chance that the "extra" nodes are simply text nodes with newlines ("\n")? There are usually a lot of extra text nodes in a file each containing only one newline.
    If you are using SAX, there is no requirement for the parser to collect all of the text inside an element into a single block before calling the characters method. You may get several calls to characters between the start of an element and the end. If you change parsers, you may even get a different number of calls, but the character data will always be the same.
    Dave Patterson
    As to the <?xml version="1.0" encoding="UTF-8"?> line, that is perfectly fine. It means that your file thinks it is valid XML. Whether or not it REALLY is valid depends on a validation of the file.

Maybe you are looking for

  • Using Left with Charindex in a Select Query

    Hi I hope someone can help me.  I have a field that has text in it for example N00342-01/28 and I am trying to get it to only show N00342-01.  This could in the future be N132245-01/25 for example or N00342-132/28.  What I am trying to show is anythi

  • Satellite 2430-101 Keyboad issue (Button "|")

    Hi the button which prints "<" , ">" and "|" doesn't work properly. I use Winxp Pro and I installed all drivers provided on the Toshiba homepage which are related to the touchpad or the keyboard. a friend of mine has the same problem, I think he has

  • Auto clear cookies greyed out

    Under tools, options, privacy, I changed the history to use custom settings, but the option to clear cookies when Firefox closes is greyed out and not usable.

  • Where is the addrress bar?

    Site loads ok, but no address bar, where i type in www.whatever.com. I have search button, but that's not what i want. I want to be able to go to any website i type in. What happened to the address bar? Or is there something wrong at my end?

  • Firefox browser won't open after Windows Troubleshooter 'fixed' FrontPage XP compatibility issue with windows 7? HELP!!

    The issue- Firefox browser won't launch. The history- Ran Windows troubleshooter to 'fix' compatibility issues running FrontPage (office xp proferssional version) on Windows 7. (Front Page opened then stopped responding partway through launch before