Writing to file more problems

I'm back... heh well now that i fixed my If statement im trying to actually write to the file, but it doesnt seem to be working... heres what i got.
public static void main (String args[])throws Exception{
Scanner in = new Scanner(new FileReader("H:/squeeze.txt"));
FileWriter out = new FileWriter("squeeze.txt");
int linecount = 0;
String line;
while(in.hasNextLine()){
line = in.nextLine();
linecount = linecount + 1;
System.out.println(""+line);
if (line.startsWith("Lisa")){
String dltspace = "balls";
out.write(dltspace, linecount, dltspace.length());
linecount = linecount - 1;
out.close();
}Now what the program is actually suppost to do is delete the spaces in front of some of the sentances. But just to experiment with it im trying to put the word balls where the word Lisa is. But nothing happens.

From the API Docs:
replace(CharSequence target, CharSequence replacement)
Replaces each substring of this string that matches the literal target sequence with the specified literal replacement sequence.
so:
myNewString = myString.replace("Lisa", "balls");Remember the resulting sting is not in myString upon completion, it's the value returned from the method. I believe it's also case sensitive, so "Lisa" and "lisa" are not the same.

Similar Messages

  • Problems with writing to file, and with ActionListener.

    I have been trying to write a Payroll Division type program as my school Computer Science Project. However, I have a few problems with it...
    import java.io.IOException;
    import java.io.FileOutputStream;
    import java.io.FileInputStream;
    import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.InputStreamReader;
    import java.io.OutputStreamWriter;
    import java.util.StringTokenizer;
    import javax.swing.*;
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.GridLayout;
    import java.awt.event.*;
    public class Personnel implements ActionListener  {    
             JFrame GUIFrame;
             JLabel ID, Line, OKText,AnswerField;
             JTextField IDField, LineField;
             JButton OK;
             JPanel GUIPanel;
             int trialCounter=0;
             final static int employeeNumber = 7;
             final static int maxValue = ((employeeNumber*4)-1);
            //Number of employees, which would be in real life passed by the Payroll division.   
            public static String [][] sortHelp = new String [employeeNumber+1][3];    /** Creates a new instance of Personnel */       
            public Personnel() {
              GUIFrame = new JFrame("PersonnelSoft"); //create title header.
                     GUIFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                     GUIFrame.setSize(new Dimension(100, 140));
                     GUIPanel= new JPanel(new GridLayout(2, 2));
                     addWidgets();
                     GUIFrame.getRootPane().setDefaultButton(OK);
                     GUIFrame.getContentPane().add(GUIPanel, BorderLayout.CENTER);
                     GUIFrame.pack();
                    GUIFrame.getContentPane().setVisible(true);
                    GUIFrame.setVisible(true);
            private void addWidgets() {
                  ID = new JLabel ("Please enter your employee Identification Number:", SwingConstants.LEFT);
                  IDField = new JTextField ("ID", 5);
                  Line = new JLabel ("Please enter the line of your payroll with which you have concerns:", SwingConstants.LEFT);
                  LineField = new JTextField ("###", 2);
                  OKText = new JLabel ("Click OK when you have verified the validity of your request", SwingConstants.LEFT);
                  OK = new JButton ("OK");
                  OK.setVerticalTextPosition(AbstractButton.CENTER);
                  OK.setMnemonic(KeyEvent.VK_I);
                  AnswerField = new JLabel("The Result of your Querie will go here", SwingConstants.LEFT);
                  GUIPanel.add(ID);
                  GUIPanel.add(IDField);
                  GUIPanel.add(Line);
                  GUIPanel.add(LineField);
                  GUIPanel.add(OKText);
                  GUIPanel.add(OK);
                  GUIPanel.add(AnswerField);
                  OK.addActionListener(this);
                  ID.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
                  OKText.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
                  Line.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
            public static void ArrayCreate() throws IOException {   
              //creates a employeeNumber x 3 array, which will hold all data neccessary for future sorting by employee ID number.      
              int counter = 2;      
              int empCounter = 1;      
              String save;
              //avoid having to waste memory calculating this value every time the for loop begins 
              FileInputStream inFile = new FileInputStream("C:\\Documents and Settings\\Abraham\\humanresource4\\src\\humanresource4\\HR.txt"); 
              BufferedReader in = new BufferedReader(new InputStreamReader(inFile));
              String line;
                    line = in.readLine();
                    StringTokenizer st = new StringTokenizer(line);
                    save = st.nextToken();
                    sortHelp[0][0] = save;
                    sortHelp[0][2] = save;
                    while (st.hasMoreTokens()) {
                    save = st.nextToken();   
                    sortHelp[0][1] = save;
                    while (counter <= maxValue) {
                    line = in.readLine();
                    if (((counter - 1) % 4) == 0) {
                    st = new StringTokenizer(line);
                    sortHelp[empCounter][0] = st.nextToken();
                    sortHelp[empCounter][2] = sortHelp[empCounter][0];
                    while (st.hasMoreTokens()) {
                    save = st.nextToken();   
                    sortHelp[empCounter][1] = save;
                    empCounter++;
                    counter++;
                 public static String[] joinString() {
                      String[] tempStorage = new String[employeeNumber+1];
                      int counter;
                      for (counter = 0; counter <= employeeNumber; counter++) {
                           tempStorage[counter] = (sortHelp[counter][1] + sortHelp[counter][0]);
                      return (tempStorage);
                 public static String[] sortEm(String[] array, int len)
                     java.util.Arrays.sort(array);
                     return array;
                 public static void splitString(String[] splitString){
                    int counter;
                    for (counter = 0; counter <= employeeNumber; counter++){
                         sortHelp[counter][0]=splitString[counter].substring( 5 );
                         sortHelp[counter][1]=splitString[counter].substring(0,5);
                 void setLabel(String newText) {
                     AnswerField.setText(newText);
                 void writetoHR(String local) throws IOException {
                      FileOutputStream outFile = new FileOutputStream ("C:\\Documents and Settings\\Abraham\\humanresource4\\src\\humanresource4\\HR2.txt");
                       BufferedWriter out = new BufferedWriter(new OutputStreamWriter(outFile));
                       out.write(local+"the preceding employee number is not in our database, but has submitted a request. Please sort out the issue");
                       System.exit(0);
                 public void actionPerformed(ActionEvent e){
                      boolean flag=false;
                      String local=IDField.getText();
                      int i=0;
                      while((i<=employeeNumber)&&(flag==false)){
                           if (sortHelp[1]==local) {
                   flag=true;
              i++;
         trialCounter++;
         if (trialCounter>=3)
              writetoHR(local);
         if (flag==false)
              setLabel("Your ID number does not exist in our records. Verify your ID and try again.");
         else {
              switch (LineField.getText())
              case 04:
                   setLabel("Your pay is calculated by multiplying your working hours by the amount per hour. If both of these fields are satisfactory to you, please contact humanresource");
                   break;
              case 03:
                   setLabel("Hourly amount was calculated by the system, by dividing your yearly pay 26 and then 80.");
                   break;
              case 07:
                   setLabel("Overtime pay was calculated by multiplying regular hourly pay by 1.1");
                   break;
              case 06:
                   setLabel("The overtime hourly pay was multiplied by the amount of overtime hours.");
                   break;
              case 10:
                   setLabel("For holiday hours, your pay is increased by 25%.");
                   break;
              case 09:
                   setLabel("The holiday hourly pay was multiplied by your amount of holiday hours.");
                   break;
              case 11:
                   setLabel("Your total pay was calculated by adding all the separate types of payment to your name.");
                   break;
              case 17:
                   setLabel("Your net pay was found by subtracting the amount withheld from your account");
                   break;
              case 19:
                   setLabel("Your sick hours remaining were taken from a pool of 96 hours.");
                   break;
              default:
                   setLabel("Please contact humanresource.");
              break;
    private static void CreateAndShowGUI() {
    JFrame.setDefaultLookAndFeelDecorated(true);
    Personnel GUI = new Personnel();
         public static void main(String[] args) throws IOException {
              String[] temporary = new String[employeeNumber];
              ArrayCreate();
    temporary = joinString();
    temporary = sortEm(temporary, employeeNumber);
    splitString(temporary);
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    CreateAndShowGUI();
    int row;
    int column;
         for (row = 0; row < (employeeNumber); row++) {    // verify proper output by ArrayCreate splitString
    for (column = 0; column <= 2; column++) {
    System.out.print(sortHelp[row][column]);
    System.out.print(' ');
    System.out.print(' ');
    System.out.println();
    1) It does not permit me to switch on a String. How do I solve that?
    2)How would I throw an exception (IO) within actionperformed?
    3)Generally, if cut it down to everything except the writing to a file part, the actionperformed script causes an error... why?
    Thanks in advance.
    And sorry for the relative lameness of my question...
    ---abe---

    Thank you very much. That did solve almost all the problems that I had...
    I just have one more problem.
    First (here's the new code):
    import java.io.IOException;
    import java.io.FileOutputStream;
    import java.io.FileInputStream;
    import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.InputStreamReader;
    import java.io.OutputStreamWriter;
    import java.util.StringTokenizer;
    import javax.swing.*;
    import java.util.*;
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.GridLayout;
    import java.awt.event.*;
      public class Personnel implements ActionListener  {    
             JFrame GUIFrame;
              JLabel ID, Line, OKText,AnswerField;
               JTextField IDField, LineField;
               JButton OK;
               JPanel GUIPanel;
               int trialCounter=0;
         final static int employeeNumber = 7;
         final static int maxValue = ((employeeNumber*4)-1);
                public static String [][] sortHelp = new String [employeeNumber+1][3];   
         public Personnel() {
              GUIFrame = new JFrame("PersonnelSoft"); //create title header.
             GUIFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
             GUIFrame.setSize(new Dimension(100, 140));
             GUIPanel= new JPanel(new GridLayout(2, 2));
             addWidgets();
             GUIFrame.getRootPane().setDefaultButton(OK);
             GUIFrame.getContentPane().add(GUIPanel, BorderLayout.CENTER);
             GUIFrame.pack();
            GUIFrame.getContentPane().setVisible(true);
            GUIFrame.setVisible(true);
            private void addWidgets() {
                  ID = new JLabel ("Please enter your employee Identification Number:", SwingConstants.LEFT);
                  IDField = new JTextField ("ID", 5);
                  Line = new JLabel ("Please enter the line of your payroll with which you have concerns:", SwingConstants.LEFT);
                  LineField = new JTextField ("###", 2);
                  OKText = new JLabel ("Click OK when you have verified the validity of your request", SwingConstants.LEFT);
                  OK = new JButton ("OK");
                  OK.setVerticalTextPosition(AbstractButton.CENTER);
                  OK.setMnemonic(KeyEvent.VK_I);
                  AnswerField = new JLabel("The Result of your Querie will go here", SwingConstants.LEFT);
                  GUIPanel.add(ID);
                  GUIPanel.add(IDField);
                  GUIPanel.add(Line);
                  GUIPanel.add(LineField);
                  GUIPanel.add(OKText);
                  GUIPanel.add(OK);
                  GUIPanel.add(AnswerField);
                  OK.addActionListener(this);
                  ID.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
                  OKText.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
                  Line.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
            public static void ArrayCreate() throws IOException {   
              int counter = 2;      
              int empCounter = 1;      
              String save;
              FileInputStream inFile = new FileInputStream("C:\\Documents and Settings\\Abraham\\humanresource4\\src\\humanresource4\\HR.txt"); 
              BufferedReader in = new BufferedReader(new InputStreamReader(inFile));
              String line;
                    line = in.readLine();
                    StringTokenizer st = new StringTokenizer(line);
                    save = st.nextToken();
                    sortHelp[0][0] = save;
                    sortHelp[0][2] = save;
                    while (st.hasMoreTokens()) {
                    save = st.nextToken();   
                    sortHelp[0][1] = save;
                    while (counter <= maxValue) {
                    line = in.readLine();
                    if (((counter - 1) % 4) == 0) {
                    st = new StringTokenizer(line);
                    sortHelp[empCounter][0] = st.nextToken();
                    sortHelp[empCounter][2] = sortHelp[empCounter][0];
                    while (st.hasMoreTokens()) {
                    save = st.nextToken();   
                    sortHelp[empCounter][1] = save;
                    empCounter++;
                    counter++;
                 public static String[] joinString() {
                      String[] tempStorage = new String[employeeNumber+1];
                      int counter;
                      for (counter = 0; counter <= employeeNumber; counter++) {
                           tempStorage[counter] = (sortHelp[counter][1] + sortHelp[counter][0]);
                      return (tempStorage);
                 public static String[] sortEm(String[] array, int len)
                     java.util.Arrays.sort(array);
                     return array;
                 public static void splitString(String[] splitString){
                    int counter;
                    for (counter = 0; counter <= employeeNumber; counter++){
                         sortHelp[counter][0]=splitString[counter].substring( 5 );
                         sortHelp[counter][1]=splitString[counter].substring(0,5);
                 void setLabel(String newText) {
                     AnswerField.setText(newText);
                 void writetoHR(String local) throws IOException {
                      FileOutputStream outFile = new FileOutputStream ("C:\\Documents and Settings\\Abraham\\humanresource4\\src\\humanresource4\\HR2.txt");
                       BufferedWriter out = new BufferedWriter(new OutputStreamWriter(outFile));
                       out.write(local+"the preceding employee number is not in our database, but has submitted a request. Please sort out the issue");
                       System.exit(0);
                 public void actionPerformed(ActionEvent e){
                      boolean flag=false;
                      String local=IDField.getText();
                      local trim();
                      int i=0;
                      while((i<employeeNumber)&&(flag==false)){
                           if (sortHelp[1]==local) {
                   flag=true;
              else {
         i++;
         trialCounter++;
         if (trialCounter>=3)
              try {
                   writetoHR(local);
              } catch (IOException exception) {
    setLabel("We are sorry. The program has encountered an unexpected error and must now close");
              } finally {
         if (flag==false)
              setLabel("Your ID number does not exist in our records. Verify your ID and try again.");
         else {
              final Map m = new HashMap();
              m.put("04","Your pay is calculated by multiplying your working hours by the amount per hour. If both of these fields are satisfactory to you, please contact humanresource.");
              m.put("03", "Hourly amount was calculated by the system, by dividing your yearly pay 26 and then 80.");
              m.put("07", "Overtime pay was calculated by multiplying regular hourly pay by 1.1");
              m.put("06", "The overtime hourly pay was multiplied by the amount of overtime hours.");
              m.put("10", "For holiday hours, your pay is increased by 25%.");
              m.put("09", "The holiday hourly pay was multiplied by your amount of holiday hours.");
              m.put("11", "Your total pay was calculated by adding all the separate types of payment to your name.");
              m.put("17", "Your net pay was found by subtracting the amount withheld from your account.");
              m.put("19", "Your sick hours remaining were taken from a pool of 96 hours.");
    setLabel(m.get(LineField.getText()));
    private static void CreateAndShowGUI() {
    JFrame.setDefaultLookAndFeelDecorated(true);
    Personnel GUI = new Personnel();
    public static void main(String[] args) throws IOException {
              String[] temporary = new String[employeeNumber];
              ArrayCreate();
    temporary = joinString();
    temporary = sortEm(temporary, employeeNumber);
    splitString(temporary);
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    CreateAndShowGUI();
    int row;
    int column;
         for (row = 0; row < (employeeNumber); row++) {    // verify proper output by ArrayCreate splitString
    for (column = 0; column <= 2; column++) {
    System.out.print(sortHelp[row][column]);
    System.out.print(' ');
    System.out.print(' ');
    System.out.println();
    Now that code above produces two errors. First of all.
    local trim();produces the error:
    Syntax error, insert "AssignmentOperator ArrayInitializer" to complete ArrayInitializerAssignementSecondly, if I take that into comments, the line
    setLabel(m.get(LineField.getText()));Produces the error:
    The method setLabel(String) in the type Personnel is not applicable for the arguments (Object)If anybody could help me solve these, I would be sincerely thankfull.
    Now, before anybody asks as to why I want to trim the String in the first place, it is due to the fact that I compare it to another String that is without whitespaces. Thus the field that DOES have whitespaces was preventing me from launching into the if loop:
    if (sortHelp[1]==local) {
                   flag=true;
    (within actionperformed) Or at least that's my explanation as to why the loop never launched. If it is wrong, can somebody please explain?)
    I apologize for the horrible indentation and lack of comments. This is an unfinished version.. I'll be adding the comments last (won't that be a joy), as well as looking for things to cut down on and make the program more efficient.
    Anyways,
    Thanks in Advance,
    ---abe---

  • Problem writing to file

    I'm working on a program that asks for the users name. after that its supposed to pull the current date and time and print that into a file along with the users name.
    my problem is when i open the .txt file i get several characters i dont recogize and then my name at the end.
    Thanks for the help:
    public class CIS314Exam1MarkWellsFrame
    private ObjectOutputStream output;
    public void openFile()
    try
    output = new ObjectOutputStream(new FileOutputStream("guestlog.txt"));
    catch(IOException ioException)
    JOptionPane.showMessageDialog(null, "You do not have access to this file");
    System.exit(1);
    public void insertName()
    try
    Date today = new Date();
    //utput.writeObject(today);
    //String name = JOptionPane.showInputDialog("Enter Name");
    String name = "Mark";
    output.writeObject(name);
    catch(IOException ioException)
    JOptionPane.showMessageDialog(null, "Error writing to file");
    return;
    public void closeFile()
    try
    if(output !=null)
    output.close();
    catch(IOException ioException)
    JOptionPane.showMessageDialog(null, "Error Closing File");
    System.exit(1);
    System.exit(0);
    }

    This isnt the correct forum for this question. Use tags when posting code.  Post the contents of the .txt file and what unexpected characters you are getting.                                                                                                                                                                                                                                                                                                                                           

  • Problem with writing to file

    What the program is supposed to do
    Print the squares of one through ten to a file whose name is typed in by the user.
    My Program
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    public class SquareSend
         private JTextField field;
         public static void main(String[] args)
              SquareSend gui = new SquareSend();
              gui.go();
         public void go()
              JFrame frame = new JFrame();
              JTextField field = new JTextField();
              field.addActionListener(new sendToFile());
              frame.getContentPane().add(BorderLayout.CENTER, field);
              frame.setSize(300, 50);
              frame.setVisible(true);
         public class sendToFile implements ActionListener
              public void actionPerformed(ActionEvent e)
                   FileOutputStream out;
                 PrintStream p;
                 try
                         out = new FileOutputStream(field.getText());
                         p = new PrintStream( out );
                         int x = 1;
                          while (x<11)
                               int y = (int)(Math.pow(x,2));
                               p.println("The square of "+x+" is "+y+".");
                               x++;                           
                         p.close();
                 catch (Exception f)
                         System.err.println ("Error writing to file");
    Error Message
    Error writing to file (display message if designated in the try...catch statement).
    Thanks for your help

    use f.printStackTrace() in your catch clause if you want more information about the exception thrown.

  • Problem in writing to file or in console

    Hi friends,
    I am here once again with one more problem.
    I read from a file and process each line and write back the result on the console. The result is strange.
    On console it starts from middle of the file and goes on reading till the end of file . Each time it trims some.
    For example I have 1500 lines. It reads, processes and writes 900 (the total is 1500) next time it may be 850 like this...
    why is like this ?
    public static void main (String[] args)throws Exception
              List one=new ArrayList();
              List A=new ArrayList();
              MyVertex j,startNode,s,targetNode;
         //load Graph
              File n=new File("nodes.txt");
              File e=new File("relation.txt");
              ts=new Test(n,e);
              //System.out.println(ts.toString());
              vs=ts.getVertexSet();
              es=ts.getEdgeSet();
              //read from file          
              BufferedReader br=new BufferedReader(new FileReader("test.txt"));
              startNodeName=br.readLine();
              while((startNodeName!=null))
                   System.out.println("START NODE : "+ startNodeName);
                                  System.out.println("links for startNodes are :     "+counter1);
                                  first(startNodeName);
                   targetNodeName=br.readLine();
                   System.out.println("TARGET NODE : "+ targetNodeName);
                   second(targetNodeName);
                   System.out.println();
                   shared();
                   System.out.println();
                   startNodeName=br.readLine();
         public static void first(String s)
         System.out.println(vs.toString());
              Iterator i=vs.iterator();
              while(i.hasNext())
                   j=(MyVertex)i.next();
                   startNode=j;
                   if(startNode.getName().equals(s))
                        one=ts.outwardNodes(startNode);
                        System.out.println(one.toString());
              counter1=one.size()+1;
         public static void second(String s)
              Iterator j=vs.iterator();
              while(j.hasNext())
                   k=(MyVertex)j.next();
                   targetNode=k;
                   if(targetNode.getName().equals(s))
                        B=ts.outwardNodes(targetNode);
                        System.out.println(B.toString());
              counter2=B.size();
              System.out.println("Links for target Nodes are :     "+counter2);
         public static void shared()
              counter3=1;
              Iterator i=one.iterator();
              while(i.hasNext())
                   s=(MyVertex)i.next();
                   if(B.contains(s))
                        counter3++;
              System.out.println("Number of common links are :     "+counter3);
              relWeight=(double)counter3/counter1;
              System.out.println("Relation weight is :     "+relWeight);
    }//end of classThanks once again

    I tried to write to a text file it is still strange. It trims some of the last lines.
    out f 1500 lines it only reads 1400 lines.
    I am using Eclipse, so I meant the console of Eclipse not windows console. In both the cases the problem remains.
    Can any one suggest me how to get rid of this problem ?
    Thanks a lot for yur time.

  • Firefox corrupted the file I download. Upon fix with reset or uninstal, more problem happened

    This all started 5 hours ago, when I tried to download a .doc file from my school website but Microsoft Word opened it with "file conversion" options and the preview is filled with unreadable codes. I was using Nightly 64-bit on a newly installed Windows 8.1 64 bit system (about a week ago after I upgrade my ssd).
    1. I tried open other .exl file from the same website, but Microsoft Excel could not open it at all saying the file is corrupted. I used IE 11 to download the same files and it worked perfectly. Problem with Nightly it looked like.
    2. I reset Nightly then tried to download the same file again, not working. Tried safemode disable all addons and try to download the .doc file. It surprisly worked!. So it seems like an addon problem. Then I disabled all addons manually restarted again but tested not working. I was really frustrated at this point so I believe my Nightly was hacked by malware or some hidden plugins.
    3. Uninstalled Nightly then I cleaned all files left with Ccleaner. I checked full scan with Windows security essential; downloaded malware cleaner "Malwarebytes". Yes a few malware like files were detected and cleaned up.
    4. Downloaded waterfox 64-bit but now more problems appeared. It still cannot download the .doc or exl file now. The right click menu is not showing up at any webpage, image or highlighted texts. Ctrl+click link to open link in new tab is not working, just nothing happens. I try to reset or safemode restart, Nope! the help menu is gone, perfectly clear!
    In brief, I would not like to reinstall my OS for this issue. I wish I could find some software remover that detects firefox virus pluggins. I don't want to try the 32-bit version of firefox for this issue.
    Thank you.

    Thanks for the fast reply.
    I deleted everything, and download the official firefox 32-bit and tried your advice disable everything. Yes it worked! it brought up the help menu.
    And the word document is working as well after I could 'help-troubleshoot-rest firefox'.
    Thank you very much. I think it was the Nightly setup naturally not compatible with .doc links. It also messed up the settings for my waterfox/firefox which I downloaded later.
    However the right-click menu is still not normal. nothing shows up nor I could open up link in a new window. This did not happened in Nightly as I stated in the original question. Any suggestions?
    Btw. After this I might stay with the official firefox 32-bit for now. is there any performance difference with 64-bit or compatible issue with Windows 8.1? I know that 64 bit firefox is not released yet.

  • Problem installing 7.6.2.9 - Error writing to file

    I've been using iTunes on this particular windows xp pro box since iTunes became available and have never had a problem until I allowed the upgrade.
    I am getting the following error dialog during the "copying files" portion of the install:
    "Error writing to file: C:\Program Files\Common Files\Apple\Mobile Device Support\etc\zoneinfo\Africa\Abidan. Verify that you have access to that directory."
    I have spent quite a bit of time trying to figure this one out. I've scanned for viruses, I've run CHKDSK, I've killed all non essential processes, etc. but continue to get this error message each time I attempt an install.
    I've read through the other posts that were similar but wondered if anyone else has seen this particular problem and been able to overcome the error. I know I could do a clean install, but have so much time invested in this current OS build that I'd rather spend some time trying to solve this. Any help out there would be greatly appreciated.
    Thanks,
    John

    I can't see the file (with hidden files turned on) unless I boot from another partition. Then I can see it, delete it, or whatever I want to do, but once I go back in and do a reinstall, I get the same problem. I've even tried to use Process Manager to try to figure it out, but so far nothing...
    It really felt like a disk problem but chkdsk reports nothing and I've had no other problems except this.

  • 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 in French translation while writing a file on application server

    I am writing some text symbols to a file on application server using Transfer statement. But for some french characters the data is not transleted correctly. I have maintained the french translation for these text symbols.

    Hi,
    Make sure you use the correct encoding while writing your file.
    Regards.

  • 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

  • Install Problem - Error Writing to file

    I am getting the following error when I try to Install the demo of 3.4.1:   Error 1304. Error writing to file   C:\ProgramData\Adobe\Cameraraw\CameraPRofiles\Camera\Nikon d40X\Nikon D40X Camera D2X Mode 2.dcp.  Verify that you have access to that directory.
    I though I changed access but it will not access when I hit  Retry.  Any suggestions?  Thanks  Alan.

    Beat:  I ran as Administrator and tried downloading a second program  Same thing.  Then I check I I saw the file was Hidden so I inchecke
    d that.  Same thing.  Then I checked the Nikon D40X folder and tried to explore it.  I got a message that the files were corrupted
    .  So apparently LR3 couldn't get in there.  SO I tried to delete that file.  No good.
    So now what?  What created that file in the first place?  Maybe I have to re-install that program.  Ignoring it as an option doesn't work.  It just ends the installatiopn of LR3.
    Any suggestions?

  • Problem installing itunes- error writing to file C:\Config.Msi\1c16cb7e.rbf. Verify that you have access to that directory. Help!!

    Every time I try to update itunes i get an error that says: error writing to file C:\Config.Msi\1c16cb7e.rbf. Verify that you have access to that directory.
    I've tried uninstalling and I the same error. Help!

    Are you running Kaspersky security software on that PC? (There's been a few reports in recent times of Kaspersky interfering with iTunes installs, with that message being produced.)
    If there is Kaspersky on board, we should try some general-principles getting-past-security-software-interference troubleshooting.
    Download and save a fresh copy of the iTunesSetup.exe (32-bit installer file) or iTunes64Setup.exe to your Hard drive. (Don't run the install on line, and don't start the install just yet.)
    http://www.apple.com/itunes/download/
    Restart the PC. After the PC restarts do not open any applications. Disconnect from your network and/or the internet. Now switch off all your security software (firewall, antivirus, antispyware).
    Now start the install by doubleclicking the iTunesSetup.exe (or iTunes64Setup.exe) file you downloaded earlier.
    Reenable all security software prior to reconnecting to your network and/or the internet.
    Any better luck with the security software shut down?

  • Update problem. "error writing to file c:\config.msi\22be9d65.rbf. Verify that you have access to that directory."

    Every time I try and update to the latest version, I get an error messages saying to manually do it from tools menu. After doing that, I get an error message saying "error writing to file c:\config.msi\22be9d65.rbf. Verify that you have access to that directory." I am the sole user on this computer and have full administrative rights to my computer. Why am I getting this? I REALY don't care if I upgrade or not but want to get rid of the stupid apple update crap that comes up everytime I turn my computer on. If there are no suggestiong on how to fix this issue, is there a way to turn apple update OFF?! I have Windows 7 Home Premium.

    Are you running Kaspersky security software on that PC? (There's been a few reports in recent times of Kaspersky interfering with iTunes installs, with that message being produced.)
    If there is Kaspersky on board, we should try some general-principles getting-past-security-software-interference troubleshooting.
    Download and save a fresh copy of the iTunesSetup.exe (32-bit installer file) or iTunes64Setup.exe to your Hard drive. (Don't run the install on line, and don't start the install just yet.)
    http://www.apple.com/itunes/download/
    Restart the PC. After the PC restarts do not open any applications. Disconnect from your network and/or the internet. Now switch off all your security software (firewall, antivirus, antispyware).
    Now start the install by doubleclicking the iTunesSetup.exe (or iTunes64Setup.exe) file you downloaded earlier.
    Reenable all security software prior to reconnecting to your network and/or the internet.
    Any better luck with the security software shut down?

  • Multithreading - writing to file

    How can I get to write the Thread name, date and time to a file with the same thread name?
    What would I need to do to write the same information 1000 times to the file? Thank you.
    import java.lang.Thread;
    import java.lang.InterruptedException;
    public class RiveraThreadsMain {
        public static void main(String[] args) {
          System.out.println("Creating threads");
          Thread riverathread0 = new Thread (new RiveraThreads ("riverathread0"));
          Thread riverathread1 = new Thread (new RiveraThreads ("riverathread1"));
          Thread riverathread2 = new Thread (new RiveraThreads ("riverathread2"));
          System.out.println("Threads created, starting tasks.");
          riverathread0.start(); // invokes thread1's run method
          riverathread1.start(); // invokes thread2's run method
          riverathread2.start(); // invokes thread3's run method
          try
           Thread.currentThread() .sleep (10000);
          catch (InterruptedException e)
            e.getStackTrace();
             System.out.printf (
             "terminated prematurely due to interruption");
          System.out.println("Tasks started, main thread ends. \n");   
        } // end main
    import java.io.File;
    import java.io.IOException;
    import java.util.NoSuchElementException;
    import java.io.FileNotFoundException;
    import java.util.Formatter;
    import java.util.NoSuchElementException;
    import java.util.Calendar;
    import java.util.Scanner;
    public class RiveraThreads implements Runnable {
    Thread launcher;
    private String taskName;
    private Scanner input;
    private Formatter output;
    // empty constructor
    public RiveraThreads (){
      public RiveraThreads (String threadName)
        launcher = new Thread ( this, threadName );
        System.out.println ( launcher.getName());
        launcher.start();
       // taskName = name; // set task name
      public void run ()
        //System.out.println(Thread.currentThread().getName());
        try
          Calendar dateTime = Calendar.getInstance();
        //  output = new Formatter (new File (launcher.getName() ));
          input = new Scanner( new File( launcher.getName() ) ); 
          output = new Formatter (new File ( launcher.getName() ));
          System.out.printf( launcher.getName() + "%tc\n", dateTime );
        }// end try
        catch ( NoSuchElementException exception)
            exception.getStackTrace();
            System.out.printf ( "%s %s \n ", taskName,
             "terminated prematurely due to interruption");
        }// end catch
        catch ( FileNotFoundException filenotfound )
            System.out.printf (" %s %s \n ", filenotfound,
              "File not found");
        catch (IOException ioexception)
          System.err.printf(
            "Unable to read file");
        // close file and terminate application
       public void closeFile()
             input.close();
          }// close file
              output.close();
       } // end method closeFile
    }

    FRiveraJr wrote:
    Hi jverd
    What are you having trouble with?
    I know how to use the BufferedReader and BufferedWriter for opening, reading and writing to file. But the trouble consists in a lot of code to write and how will I call the appropriate file name since it is supposed to be
    the same name as the thread into all of this? I still don't know what problem you're having.
    You know how to provide a file name, right?
    Do you know how to get a thread name?
    If both are "yes", then I don't see what's left that you'd be having problems with. You need to be specific. Nobody here can read your mind, since it's the holidays.
    Writing to a file?
    Yes, I'm getting the correct results to the console with the thread name and the calendar option with the date and time and this is the data that needs to be written to a file. Isn't there a more simple way?A simpler way than your current code? How can anybody answer that without seeing your code?
    What would I need to do to write the same information 1000 times to the file?
    Because that is part of the requirements. Is not that I am insane :0).... This is just part of developing my skills since I'm new to all this. So, do you still have a question about this part? You do know how to loop, right? If not, you shouldn't be getting anywhere near I/O or multithreading.

  • I get the following error message when trying to download ITunes on my computer running Windows XP - Error writing to file: C:\Program Files\Common Files\Apple Application Support\CFNetwork.dll

    I get the following error message when trying to download ITunes on my computer running Windows XP - Error writing to file: C:\Program Files\Common Files\Apple Application Support\CFNetwork.dll

    For general advice see Troubleshooting issues with iTunes for Windows updates.
    The steps in the second box are a guide to removing everything related to iTunes and then rebuilding it which is often a good starting point unless the symptoms indicate a more specific approach. Review the other boxes and the list of support documents further down the page in case one of them applies.
    The further information area has direct links to the current and recent builds in case you have problems downloading, need to revert to an older version or want to try the iTunes for Windows (64-bit - for older video cards) release as a workaround for installation or performance issues, or compatibility with QuickTime or third party software.
    Your library should be unaffected by these steps but there also links to backup and recovery advice should it be needed.
    tt2

Maybe you are looking for