Saving multiple lines in a file

ok I have a simple calculator that when you inset the text into text fiel one and when you insert text into tex input 2 when you hit the add subtract or any of the other buttons it will add the date, time, input 1, input 2, calculation performed, and answer. It is also supposed to be able to store each calculation not just one. I am kinda new to programming in Java and would love some hel here is my code
import java.awt.*;
import javax.swing.*;
import java.awt.event.*; // added
import java.io.*;
import java.util.*;
public class JohnathanNoeExam7 extends JFrame {
     private Container contentPane;
     private JPanel leftPanel;
     private JPanel centerPanel;
     private JPanel buttonPanel;
     public JTextField input1TextField;
     private JTextField input2TextField;
     private JLabel answerLabel;
     private JButton plusButton;
     private JButton minusButton;
     private JButton divisionButton;
     private JButton multiplyButton;
     private JButton modulusButton;
     public JohnathanNoeExam7() {     
          super("Simple Calculator");
          contentPane = this.getContentPane();
          this.setSize(250, 100);
          Dimension frameSize = this.getSize();
          Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
          this.setLocation((screenSize.width - frameSize.width)/2,
                            (screenSize.height - frameSize.height)/2);
          leftPanel = new JPanel();
          leftPanel.setLayout(new GridLayout(3, 1));
          leftPanel.add(new JLabel("Input 1:  "));
          leftPanel.add(new JLabel("Input 2:  "));
          leftPanel.add(new JLabel("Answer:  "));
          contentPane.add(leftPanel, BorderLayout.WEST);
          centerPanel = new JPanel();
          centerPanel.setLayout(new GridLayout(3, 1));
          input1TextField = new JTextField(10);
          input2TextField = new JTextField(10);
          answerLabel = new JLabel();
          centerPanel.add(input1TextField);
          centerPanel.add(input2TextField);
          centerPanel.add(answerLabel);
          contentPane.add(centerPanel, BorderLayout.CENTER);
          buttonPanel = new JPanel();
          buttonPanel.setLayout(new GridLayout(5, 1));
          plusButton = new JButton("+");
          minusButton = new JButton("-");
          divisionButton = new JButton("/");
          multiplyButton = new JButton("*");
          modulusButton = new JButton("%");
          buttonPanel.add(plusButton);
          buttonPanel.add(minusButton);
          buttonPanel.add(divisionButton);
          buttonPanel.add(multiplyButton);
          buttonPanel.add(modulusButton);
          contentPane.add(buttonPanel, BorderLayout.EAST);
          ActionListener l = new ActionListener() {
              public void actionPerformed(ActionEvent e) {
               double d1 = Double.parseDouble(input1TextField.getText());
               double d2 = Double.parseDouble(input2TextField.getText());
               if (e.getSource() == plusButton)
                    answerLabel.setText("" + (d1 + d2));
               else if (e.getSource() == minusButton)
                    answerLabel.setText("" + (d1 - d2));
               else if (e.getSource() == divisionButton)
                    answerLabel.setText("" + (d1 / d2));
               else if (e.getSource() == multiplyButton)
                    answerLabel.setText("" + (d1 * d2));
               else answerLabel.setText("" + (d1 % d2));
               FileOutputStream out;
               PrintStream p;     
               double d3 = Double.parseDouble(answerLabel.getText());
               try
                    out = new FileOutputStream("Calculation.log");
                    p = new PrintStream( out );
                    p.println("Input 1: " + d1 + " "  + "Input 2: " + " " + d2 + " " + "Answer: " + d3);
                    p.close();
               catch(Exception f)
                    System.err.println("Error writing to file");
          plusButton.addActionListener(l);
          minusButton.addActionListener(l);
          divisionButton.addActionListener(l);
          multiplyButton.addActionListener(l);
          modulusButton.addActionListener(l);
          WindowListener w = new WindowAdapter() {
              public void windowClosing(WindowEvent e) {
               // Note the need to preface "this." with
               // the name of the outer class.
                   JohnathanNoeExam7.this.dispose();
               System.exit(0);
          this.addWindowListener(w);
            this.setVisible(true);
                  public static void main(String args[]){
          new JohnathanNoeExam7();
}Thanks for any help you can provide

I didn't look at anything else but if you want to write more than one line ever to your file you should change this
out = new FileOutputStream("Calculation.log");to this...
out = new FileOutputStream("Calculation.log",true);A quick look at the API reveals the follow constructor FileOutputStream(File file, boolean append) append means should I add on the end of the file or over-write what is there.
By default you over-write. So in our case we say true instead which says add on to what is there.
At the end of that little snippet you shoudl be closing that stream as well.
So where you have
p.close();You should have
p.close();
out.close();

Similar Messages

  • Reading Multiple lines in a file Using File Adapter

    Hi All,
    Iam new to this technology.How to read multiple lines in a file using file adapter.Brief me with the methodology.

    I didn't look at anything else but if you want to write more than one line ever to your file you should change this
    out = new FileOutputStream("Calculation.log");to this...
    out = new FileOutputStream("Calculation.log",true);A quick look at the API reveals the follow constructor FileOutputStream(File file, boolean append) append means should I add on the end of the file or over-write what is there.
    By default you over-write. So in our case we say true instead which says add on to what is there.
    At the end of that little snippet you shoudl be closing that stream as well.
    So where you have
    p.close();You should have
    p.close();
    out.close();

  • Pass Idoc PO Multiple Line Items to file

    Hello All,
    we are using Message Type ORDERS and ORDERS1 as Basic type to pass PO and sales data. I have configured IDOC to File scenario. I'm able to successfully place a file in file folder.
    But my issue is some of the PO's have multiple line items and saved file has one first line item information. I have even tried unbounded for line item but no luck.
    <b>How do I pass all the line item values to the file ?.</b>
    The output structure should be
    1. PO Number
    2. PO ITem
    3. Material No
    4. Delivery Date
    5. Vendor Number
    the data type I created is
    Pur_Ord
    |__ EBELN
    |__ EBELP  0..Unbounded
    |__ MATNR
    |__ AEDAT
    |__ LIFNR
    the current output is
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:Pur_Ord_Out xmlns:ns0="http://PO_TO_FILE">
      <EBELN>0004500066</EBELN>
      <EBELP>00001</EBELP>
      <MATNR>000000000000010027</MATNR>
      <AEDAT>20051215</AEDAT>
      <LIFNR>0001005780</LIFNR>
    </ns0:Pur_Ord_Out>
    Im looking for an output with all line items
    Thanks in advance
    Praveen

    Praveen
    Try this
    Pur_Ord
    |__ ORDERS 0.. Unbounded
      |__ EBELN
      |__ EBELP
      |__ MATNR
      |__ AEDAT
      |__ LIFNR
    Here ORDERS is the parent node.
    KK
    Message was edited by: KK

  • Script or command line to comment out multiple lines in flat files

    I am looking for a way to go through multiple flat files within the same directory for the occurance of a server name and if found to insert a comment (#) at the beginning of the line. Currently, I am grepping for the server name within the directory and then doing a vi on each individual flat file to comment out the line. The server name is separated by the pipe (|) symbol and each line of every file is in this format:
    webservers:WEBSERVER|Env Name|servername|application name
    So, in the above, I am grepping for the servername part and if found in there, I want to change the line to:
    #webservers:WEBSERVER|Env Name|servername|application name
    I would think there would be a way of doing this either with command line Perl or with maybe awk or sed. Any suggestions would be greatly appreciated.

    You could do something like this with a ksh shell script:
    #!/usr/bin/ksh
    for file in `ls`; do
            echo $file
            sed 's/^webserver/#webserver/g' $file > $file.parsed; mv $file.parsed $file
    doneThis will go through everyfile in the directory and search for "start of line" webserver and replace it with "#webserver". Then the file will get move back to the original file name.
    If you just want to change certain files ie. only filenames with the word "server" in it, then change:
    for file in `ls`; do to something like
    for file in `ls *server*`; doHope this help...
    Cheers
    pdaemon

  • While saving multiple attachments from mail, files with same name are added and not replaced

    While saving Multiple Attachments from Mail, existing file with same name are not overwritted but new files are added in the folder.

    Bjørn Larsen a écrit:
    Hi all
    Hope to get some help with Elements Organizer.
    I have 12-15 years of digital photos that I now want to import into my newly aquirede Adobe Elements Organizer / Photoshop. Since my Nikon names the files with continous numbers from 0001 to 9999 I have multiple files with the same name although they are not alike at all. My previous software had no problems with that since I keep the photos in separate file folders based on import date. I generally import photos after each event and so name the folder with the date and some event info (e.g. 2014.12.24 - Christmas at grandparents).
    That is a common situation, I have the same limitation for files not going over 9999 on my Canons...
    Now - when I import my photos into Elements Organizer I get a lot of error messages with "same name exist .....) Hmmmmmmm
    Please sate the exact wording of the error message, I have never seen a message stating 'same name exist...' or equivalent; only messages about files already in the catalog. Files already in the catalog mean that some files have the same 'date taken' and file size in Kb.
    Any suggestions. I'm using a mac and tried to rename files based on date taken. The mac can do that but it takes ages to go into each folder and run the renaming script there.
    I also use a similar folder creation scheme (such a date naming is the default for the downloader). That way I never get a message about duplicates for the same file names.
    However - I can't be the first or only person with this problem so I figure that some workaround must be known out there. Maybe the import action can recognize date taken or - well. Thank you very much in advance if you can help me out here.
    You can alsways set the downloader to rename the imported files with a unique new name, there are many options in the 'advanced' dialog of the downloader. I don't know about Macs, but I don't thing there is a difference.

  • Saving multiples objects into a file

    I want to create a single file that has multiples things inside, like pictures (png) and texts. Does someone knows how it will be the structure of the binary file?
    I'm programming a draw software like photoshop, where my layers are BufferedImages. Theses bufferedImages must be saved into a file to re-open later and edit.
    Please I want just ideas....
    thanks

    If the objects that you store in your file are fairly independent of each other, one thing that comes
    to mind is to make your file a zip file of component files. That way you can use standard tools to examine
    it and edit it if you wish.
    Another thing to note is that if your file is largely a series of images, some image file formats,
    like tiff , jpeg and gif allow you to store sequences of images in one file.
    Here's a demo that creates a tiff file holding four images, then reads the file and displays the images.
    Stardard software like Kodak's "Imaging Preview" will allow you to flip through the images in the file.
    By the way, if you don't have readers/writers for format tiff, you can get them here.
    import java.awt.*;
    import java.awt.image.*;
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import javax.imageio.*;
    import javax.imageio.stream.*;
    import javax.swing.*;
    public class IOExample {
        public static void main(String[] args) throws IOException {
            String urlPrefix = "http://www3.us.porsche.com/english/usa/carreragt/modelinformation/experience/desktop/bilder/icon";
            String urlSuffix = "_800x600.jpg";
            int SIZE = 4;
            BufferedImage[] images = new BufferedImage[SIZE];
            for(int i=1; i<=SIZE; ++i)
                images[i-1] = ImageIO.read(new URL(urlPrefix + i + urlSuffix));
            File file = new File("test.tiff");
            file.delete();
            int count = writeImages(images, file);
            if (count < SIZE)
                throw new IOException("Only " + count + " images written");
            images = null;
            images = readImages(file);
            if (images.length < SIZE)
                throw new IOException("Only " + images.length + " images read");
            display(images);
        public static void display(BufferedImage[] images) {
            JFrame f = new JFrame("IOExample");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JPanel p = new JPanel(new GridLayout(0,1));
            for(int j=0; j<images.length; ++j) {
                JLabel label = new JLabel(new ImageIcon(images[j]));
                label.setBorder(BorderFactory.createEtchedBorder());
                p.add(label);
            f.getContentPane().add(new JScrollPane(p));
            f.setSize(400,300);
            f.setLocationRelativeTo(null);
            f.setVisible(true);
        //suffix is "jpeg", "gif", "png", etc... according to your service providers
        public static ImageWriter getWriter(String suffix) throws IOException {
            Iterator writers = ImageIO.getImageWritersBySuffix(suffix);
            if (!writers.hasNext())
                throw new IOException("no writers for suffix " + suffix);
            return (ImageWriter) writers.next();
        public static ImageReader getReader(String suffix) throws IOException {
            Iterator readers = ImageIO.getImageReadersBySuffix(suffix);
            if (!readers.hasNext())
                throw new IOException("no reader for suffix " + suffix);
            return (ImageReader) readers.next();
        public static int writeImages(BufferedImage[] sources, File destination) throws IOException {
            if (sources.length == 0) {
                System.out.println("Sources is empty!");
                return 0;
            } else {
                ImageWriter writer = getWriter(getSuffix(destination));
                ImageOutputStream out = ImageIO.createImageOutputStream(destination);
                writer.setOutput(out);
                writer.prepareWriteSequence(null);
                for(int i=0; i<sources.length; ++i)
                    writer.writeToSequence(new IIOImage(sources, null, null), null);
    writer.endWriteSequence();
    return sources.length;
    public static BufferedImage[] readImages(File source) throws IOException {
    ImageReader reader = getReader(getSuffix(source));
    ImageInputStream in = ImageIO.createImageInputStream(source);
    reader.setInput(in);
    ArrayList images = new ArrayList();
    GraphicsConfiguration gc = getDefaultConfiguration();
    try {
    for(int j=0; true; ++j)
    images.add(toCompatibleImage(reader.read(j), gc));
    } catch(IndexOutOfBoundsException e) {
    return (BufferedImage[]) images.toArray(new BufferedImage[images.size()]);
    public static String getSuffix(File file) throws IOException {
    String filename = file.getName();
    int index = filename.lastIndexOf('.');
    if (index == -1)
    throw new IOException("No suffix given for file " + file);
    return filename.substring(1+index);
    //make compatible with gc for faster rendering
    public static BufferedImage toCompatibleImage(BufferedImage image, GraphicsConfiguration gc) {
    int w = image.getWidth(), h = image.getHeight();
    int transparency = image.getColorModel().getTransparency();
    BufferedImage result = gc.createCompatibleImage(w, h, transparency);
    Graphics2D g = result.createGraphics();
    g.drawRenderedImage(image, null);
    g.dispose();
    return result;
    public static GraphicsConfiguration getDefaultConfiguration() {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gd = ge.getDefaultScreenDevice();
    return gd.getDefaultConfiguration();

  • Saving multiple records into text file

    Can I save multiple records into a text file at one go?
    My application has a list of data displayed there and when the user clicks on the save button it will save all the records on the screen.
    It works but it only saves the last record.
    Here are my codes
    // this is to display the list of data
    private JLabel[] subjects=new JLabel[20];
    private JLabel[] subTotal=new JLabel[20];
    private JLabel[] codes=new JLabel[20];
    private JLabel[] getTotal=new JLabel[20];
    String moduleCodes;
    String getPrice;
    double price;
    int noOfNotes;
    public testapp(Subjects[] subList)
    int j=0;
                double CalTotal=0;
              for (int i=0; i<subList.length; i++)
                   subjects[i] = new JLabel();
                   subTotal[i] = new JLabel();
                   codes=new JLabel();
                   getTotal[i]=new JLabel();
                   if (subList[i].isSelected)
                        System.out.println(i+"is selected");
                        subjects[i].setText(subList[i].title);
                        subjects[i].setBounds(30, 140 + (j*30), 400, 40);
                        subTotal[i].setText("$"+subList[i].price);
                        subTotal[i].setBounds(430,140+(j*30),100,40);
                        codes[i].setText(subList[i].code);
                        getTotal[i].setText(subList[i].price+"");
                        CalTotal+=subList[i].price;
                        contain.add(subjects[i]);
                        contain.add(subTotal[i]);
                        j++;
                        moduleCodes=codes[i].getText();                              
                        getPrice=getTotal[i].getText();
                        noOfNotes=1;
    // this is where the records are saved
         public void readRecords(String moduleCodes,String getPrice,int notes)throws IOException
              price=Double.parseDouble(getPrice);
              String outputFile = "testing.txt";
              FileOutputStream out = new FileOutputStream(outputFile, true);      
         PrintStream fileOutput = new PrintStream(out);
              SalesData[] sales=new SalesData[7];
              for(int i=0;i<sales.length ;i++)
                   sales[i]=new SalesData(moduleCodes,price,notes);
                   fileOutput.println(sales[i].getRecord());
              out.close();

    I suggest writing a method that takes a SalesData[]
    parameter and a filename. Example:
    public void writeRecords(SalesData[] data,
    String filename) throws IOException
    BufferedWriter out = new BufferedWriter(new
    FileWriter(filename, true));
    for (int i = 0; i < data.length; i++)
    out.write(data.getRecord());
    out.newLine();
    out.close();
    And it's good to get in the habit of doing things like closing resources in finally blocks.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Wmic-output of multiple lines to one file

    Hell all.
    I hope that someone can help me with this:
    I have the following that I want to write to one  .html file.
    wmic /Output:G:\%computername%.html os get Name, ServicePackMinorVersion /Format:htable
    wmic /Output:G:\%computername%.html computersystem get Name,Manufacturer,Model /Format:htable
    wmic /Output:G:\%computername%.html diskdrive get model,name,size /Format:htable
    How can I re direct it so that it will write all that info  to one html file?
    Any idea?
    Thanks in advance.

    Hi,
    As far as I can see you use /output command to point a location to save the result, and if you want to save all those information to a same file, I think we can use /APPEND parameter, please go through the below link for more details about WMIC command:
    http://www.petri.co.il/command-line-wmi-part-3.htm
    http://technet.microsoft.com/en-us/library/cc787035(v=ws.10).aspx
    Regards,
    Yan Li
    Regards, Yan Li

  • Saving multiple signals to ASCII file

    How can I save two (or more) signals from different sources to same ASCII file? I want to be able to compare the wanted and the actual measured signal by looking the ASCII file result...
    The result file (sweep.txt) could look like this:
    DC Signal  mean
    1                 0.99
    2                 2.1
    3                 3.0
     My little sequence looks like this
    Sweep (from 0V to 5V, 0.5 steps)
      Create analog signal
       |> DC signal
      DAQmxGenerate
      >| DC Signal
      DAQmx Acquire (10 samples)
      |> Voltage
      Statistics
      >| Voltage
      |> mean
      Save to ASCII/LVM
      >| mean
      >| DC Signal (I can't seem to add another source like this!!!)
    End sweep
    The way the Save step acts when trying to add another signal is rather...chaotic! You can TRY to add another signal but you can't select it, OR if you can select it it will cause an error later on...(Missing input)
    And if I choose to export DC Signal and mean from the sweep output and then save it...The header talkes about "Frequency (Hz)" which is not related to the measurement at all...so it seems there are bugs in the software or my reasoning...And I can't seem to change the header either!
    Shouldn't it be possible to save lots of different measurement data from different devices?!?! It seems like a normal thing to do!!
    ...My next sequence was supposed to measure the effiency of a regulator by sweeping the input voltage Uin (100 points) and the load resistance Rload (100 points ) and save the results in a file looking like this: (total of about 100x100 measurements)
    Uin Iin Pin Uout Iout Rload Pload n
    Oh and BTW i'm using Signal Express 2.5.0, is there an update availlable?
    Thanks...
    -Sami

    I can think of a couple of issues that may be causing your frustrations. 
    Issue 1:
    The DC signal coming from the Create Signal step is actually a waveform with multiple samples, not just a single value.  The mean value is a double with one value.  The Save to ASCII/LVM step is not set up to save inputs of different types to the same file.  Since they can have different lengths, putting them side-by-side into the same file doesn't make sense. 
    Try doing just a save of the DC signal and then another of the mean value and then take a look at the output data and you'll see the difference.
    Issue 2:
    When you have outputs of a Sweep, the outputs are functions of the selections made in the Sweep Output tab.  This allows the values of signals vs. the swept parameter, so you may have the DC signal swept against the frequency changes in the Sweep step.  Check the Sweep Output tab to verify you're sending out the data you want.
    Adam.

  • How to validate multiple lines which is exist in the form builder at the same session

    Hi All,
    we are working on oracle Forms personalization to trigger the message at the point of saving multiple lines rather than requiring each line to be save individually. Currently the oracle form is allowing to user to enter two distinct lines that have same resource and basis type in BOM.
    Currently the Oracle form is allowing to enter the duplicate combination and not giving any error message even we enter the same combination of data.
    As per the customer requirement, they don’t want to validate the data while creating the records but when they try to save the form, in that case it should validate all the records at a time then need to display the appropriate message.
    Customer don’t want to customize the Oracle standard form. Here we have only option to use form personalization or through custom.pll.
    Any idea on how to validate multiple lines which is exist in the form builder at the same session as before inserting the record itself need to perform the validations for all the records.
    Thanks for your help in this regard.
    Regards,
    Thirupathi

    you can write a post script which will do the necessary tasks.
    I mean, once you are done with inserting records into these tables, exeute another procedure which will insert these "extra" records, based on some logic.
    you may not be able use DB trigger as it may generate mutating error or if you don't write it carefully, it will go into recursive loops as you are refering to same tables.
    HTH

  • Replacing multiple lines of text in a file

    Hello
    I have an interesting problem
    I have a scheduling software which outputs a iCalendar file - this iCalendar file can be read by Kontact but all the events have NO alarm
    I Checked the file and what I need to add is :
    BEGIN:VALARM
    DESCRIPTION:
    ACTION:DISPLAY
    TRIGGER;VALUE=DURATION:-PT15M
    END:VALARM
    before
    END:VEVENT
    problem is that
    1) the scheduling software exports the file often - so any modification would be overwritten - which means I have to have the script run periodically
    2) the script shouldn't run more than once on the file otherwise I would get multiple alarm tags...
    what I though of doing is
    check for
    TZID:America/Toronto
    END:VEVENT
    and replace it with
    TZID:America/Toronto
    BEGIN:VALARM
    DESCRIPTION:
    ACTION:DISPLAY
    TRIGGER;VALUE=DURATION:-PT15M
    END:VALARM
    END:VEVENT
    which should prevent all problems.
    Now the big problem is that I have not found a single way around to have a script doing this for me.
    I have tried sed but it doesn't support multiple lines
    I have tried awk which is able to insert multile lines but somehow cannot search for multiple lines
    The added complication is that I have a lot of special characters in the text to search and replace
    any of you good souls can help me with this???
    Cippa

    This should work:
    #!/bin/bash
    INSERT='BEGIN:VALARM\nDESCRIPTION:\nACTION:DISPLAY\nTRIGGER;VALUE=DURATION:-PT15M\nEND:VALARM'
    sed -e "/TZID:America\/Toronto$/N;s/\(TZID:America\/Toronto\)\n\(END:VEVENT\)/\1\n$INSERT\n\2/" $1
    I just learned from http://www.shell-fu.org/lister.php?id=539

  • Multiple lines in File adapter

    Hi Friends ,
    I am using a file to Idoc scenerio,I had to write the tdline field , which is multiple lines in idoc to a field in file .
    My file structre is simple :  No hierchries in the fields . Assume f is long text field .
    I have defined field f as 0:unbounded .
    In content conversion parameters :
    Recordset :  row, *
    My structure is :
    a
    b
      row
       e
       f(long text field)
       g
       h
    Now what happens is , if the TDLINE has multiple lines , the the data in file appears with Pipe seperator .
    In my case , I have used Pipe as field seperator .
    Please suggest .
    Chan

    Hi Vijay,
    As u mentioned in earlier post...
    keyfieldName = TABNAM
    EDI_DC40.fieldNames :
    EDI_DC40. fieldFixedLengths:
    EDI_DC40.keyFieldValue :
    E1WPU01.fieldNames :
    E1WPU01.fieldFixedLengths:
    E1WPU01.keyFieldValue
    E1WPU02.fieldNames :
    E1WPU02.fieldFixedLengths:
    E1WPU02.keyFieldValue
    Here actually you are trying to get the key field value even from EDI_DC40 and E1WPU01 also....
    So obviously u dnt have those values in that rows so.. it cannot get the rows....
    So please u try this one..... The same FCC but remove the 2 lines.... for EDI_DC40 and  E1WPU01
    keyfieldName = TABNAM
    EDI_DC40.fieldNames :
    EDI_DC40. fieldFixedLengths:
    E1WPU01.fieldNames :
    E1WPU01.fieldFixedLengths:
    E1WPU02.fieldNames :
    E1WPU02.fieldFixedLengths:
    E1WPU02.keyFieldValue
    I hope this wil solve ur problem..
    Lemme know if any issues...
    Thanks & Regards,
    H.L.Babu

  • Saving large tiff files we see a lot of times the lines in the saved file that have either missing ( white) pixels or they appear as a black line across entire file or portion of it

    saving large tiff files we see a lot of times the lines in the saved file that have either missing ( white) pixels or they appear as a black line across entire file or portion of it

    Due to the current unavailability of clairvoyants and mind-readers in the forum, we respectfully request you supply sensible, complete details.
    BOILERPLATE TEXT:
    Note that this is boilerplate text.
    If you give complete and detailed information about your setup and the issue at hand,
    such as your platform (Mac or Win),
    exact versions of your OS, of Photoshop (not just "CS6", but something like CS6v.13.0.6) and of Bridge,
    your settings in Photoshop > Preference > Performance
    the type of file you were working on,
    machine specs, such as total installed RAM, scratch file HDs, total available HD space, video card specs, including total VRAM installed,
    what troubleshooting steps you have taken so far,
    what error message(s) you receive,
    if having issues opening raw files also the exact camera make and model that generated them,
    if you're having printing issues, indicate the exact make and model of your printer, paper size, image dimensions in pixels (so many pixels wide by so many pixels high). if going through a RIP, specify that too.
    A screen shot of your settings or of the image could be very helpful too,
    etc.,
    someone may be able to help you (not necessarily this poster, who is not a Windows user).
    Please read this FAQ for advice on how to ask your questions correctly for quicker and better answers:
    http://forums.adobe.com/thread/419981?tstart=0
    Thanks!

  • RandomAccessFile: How do I Clear the txt file and write multiple lines of..

    Hello all,
    I am a 6th grade teacher and am taking a not so "Advanced Java Programming" class. Could someone please help me with the following problem.
    I am having trouble with RandomAccessFile.
    What I want to do is:
    1. Write multiple lines of text to a file
    2. Be able to delete previous entries in the file
    3. It would also be nice to be able to go to a certian line of text but not manditory.
    import java.io.*;
    public class Logger
    RandomAccessFile raf;
    public Logger()
         try
              raf=new RandomAccessFile("default.txt","rw");
              raf.seek(0);
              raf.writeBytes("");
         catch(Exception e)
              e.printStackTrace();
    public Logger(String fileName)
         try
              raf=new RandomAccessFile(fileName,"rw");
              raf.seek(0);
              raf.writeBytes("");
         catch(Exception e)
              e.printStackTrace();
    public void writeLine(String line)
         try
              long index=0;
              raf.seek(raf.length());          
              raf.writeBytes(index+" "+line);
         catch(Exception e)
              e.printStackTrace();
    public void closeFile()
         try
              raf.close();
         catch(Exception e)
              e.printStackTrace();
         }

    Enjoy! The length of the code is highly attributable to the test harness/shell thingy at the end. But anyway seems to work nicely.
    import java.io.*;
    /** File structure is as follows. 1st four bytes (int) with number of live records. Followed by records.
    <p>Records are structured as follows<ul>
    <li>Alive or dead - int
    <li>Length of data - int
    <li>Data
    </ul>*/
    public class SequentialAccessStringFile{
      private static int ALIVE = 1;
      private static int DEAD = 0;
      private int numRecords, currentRecord;
      private RandomAccessFile raf;
      /** Creates a SequentialAccessStringFile from a previously created file. */
      public SequentialAccessStringFile(String filename)throws IOException{
        this(filename,false);
      /** Creates a SequentialAccessStringFile. If createnew is true then a new file is created or if it
          already exists the old one is blown away. You must call this constructor with true if you do
          not have an existing file. */
      public SequentialAccessStringFile(String filename, boolean createnew)throws IOException{
        this.raf = new RandomAccessFile(filename,"rw");
        if(createnew){
          truncate();
        this.currentRecord = 0;
        this.raf.seek(0);
        this.numRecords = raf.readInt();
      /** Truncates the file deleting all existing records. */
      public void truncate()throws IOException{
        this.numRecords = 0;
        this.currentRecord = 0;
        this.raf.setLength(0);
        this.raf.writeInt(this.numRecords);
      /** Adds the given String to the end of this file.*/
      public void addRecord(String toAdd)throws IOException{
        this.raf.seek(this.raf.length());//jump to end of file
        byte[] buff = toAdd.getBytes();// uses default encoding you may want to change this
        this.raf.writeInt(ALIVE);
        this.raf.writeInt(buff.length);
        this.raf.write(buff);
        numRecords++;
        this.raf.seek(0);
        this.raf.writeInt(this.numRecords);
        this.currentRecord = 0;   
      /** Returns the record at given index. Indexing starts at zero. */
      public String getRecord(int index)throws IOException{
        seekToRecord(index);
        int buffLength = this.raf.readInt();
        byte[] buff = new byte[buffLength];
        this.raf.readFully(buff);
        this.currentRecord++;
        return new String(buff); // again with the default charset
      /** Returns the number of records in this file. */
      public int recordCount(){
        return this.numRecords;
      /** Deletes the record at given index. This does not physically delete the file but simply marks the record as "dead" */
      public void deleteRecord(int index)throws IOException{
        seekToRecord(index);
        this.raf.seek(this.raf.getFilePointer()-4);
        this.raf.writeInt(DEAD);
        this.numRecords--;
        this.raf.seek(0);
        this.raf.writeInt(this.numRecords);
        this.currentRecord = 0;
      /** Removes dead space from file.*/
      public void optimizeFile()throws IOException{
        // excercise left for reader
      public void close()throws IOException{
        this.raf.close();
      /** Positions the file pointer just before the size attribute for the record we want to read*/
      private void seekToRecord(int index)throws IOException{
        if(index>=this.numRecords){
          throw new IOException("Record "+index+" out of range.");           
        if(index<this.currentRecord){
          this.raf.seek(4);
          currentRecord = 0;     
        int isAlive, toSkip;
        while(this.currentRecord<index){
          //skip a record
          isAlive = this.raf.readInt();
          toSkip = this.raf.readInt();
          this.raf.skipBytes(toSkip);
          if(isAlive==ALIVE){
               this.currentRecord++;
        // the next live record is the record we want
        isAlive = this.raf.readInt();
        while(isAlive==DEAD){
          toSkip = this.raf.readInt();
          this.raf.skipBytes(toSkip);
          isAlive = this.raf.readInt();     
      public static void main(String args[])throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        System.out.println("Create a new file? y/n");
        System.out.println("(No assumes file exists)");
        System.out.print("> ");
        String command = br.readLine();
        SequentialAccessStringFile test = null;
        if(command.equalsIgnoreCase("y")){
          System.out.println("Name of file");
          System.out.print("> ");
          command = br.readLine();
          test = new SequentialAccessStringFile(command,true);     
        }else{
          System.out.println("Name of file");
          System.out.print("> ");
          command = br.readLine();
          test = new SequentialAccessStringFile(command);     
        System.out.println("File loaded. Type ? for help");
        boolean alive = true;
        while(alive){
          System.out.print("> ");
          command = br.readLine();
          boolean understood = false;
          String[] commandArgs = command.split("\\s");
          if(commandArgs.length<1){
               continue;
          if(commandArgs[0].equalsIgnoreCase("quit")){
               test.close();           
               alive = false;
               understood = true;           
          if(commandArgs[0].equalsIgnoreCase("list")){
               System.out.println("#\tValue");
               for(int i=0;i<test.recordCount();i++){
                 System.out.println(i+"\t"+test.getRecord(i));
               understood = true;
          if(commandArgs[0].equalsIgnoreCase("truncate")){
               test.truncate();
               understood = true;
               System.out.println("File truncated");
          if(commandArgs[0].equalsIgnoreCase("add")){
                test.addRecord(commandArgs[1]);
                understood = true;
                System.out.println("Record added");
          if(commandArgs[0].equalsIgnoreCase("delete")){
                int toDelete = Integer.parseInt(commandArgs[1]);
                if((toDelete<0)||(toDelete>=test.recordCount())){
                  System.out.println("Record "+toDelete+" does not exist");
                }else{
                  test.deleteRecord(toDelete);
                  System.out.println("Record deleted");
                understood = true;
          if(commandArgs[0].equals("?")){
               understood = true;
          if(!understood){
               System.out.println("'"+command+"' unrecognized");
               commandArgs[0] = "?";
          if(commandArgs[0].equals("?")){
               System.out.println("list - prints current file contents");
               System.out.println("add [data] - adds data to file");
               System.out.println("delete [record index] - deletes record from file");
               System.out.println("truncate - truncates file (deletes all record)");
               System.out.println("quit - quit this program");
               System.out.println("? - displays this help");
        System.out.println("Bye!");
    }Sample output with test program
    C:\>java SequentialAccessStringFile
    Create a new file? y/n
    (No assumes file exists)
    yName of file
    mystringsFile loaded. Type ? for help
    add appleRecord added
    add orangeRecord added
    add cherryRecord added
    add pineappleRecord added
    list#       Value
    0       apple
    1       orange
    2       cherry
    3       pineapple
    delete 5Record 5 does not exist
    delete 1Record deleted
    list#       Value
    0       apple
    1       cherry
    2       pineapple
    add kiwiRecord added
    list#       Value
    0       apple
    1       cherry
    2       pineapple
    3       kiwi
    quitBye

  • How to read multiple lines from an external file to the Oracle data base

    Hi Guys,
    I have an external file which contains multiple lines and I want to read it to the data base .I have done it for the file if it contains one line.
    Please guide me how to retrieve all the lines into the data base.And also tell me how Oracle will come to know the end of the line in the file
    Thanks,
    Prafulla

    Hi,
    try this
    CREATE TABLE ab
    a VARCHAR2(1 BYTE),
    b VARCHAR2(2 BYTE),
    c VARCHAR2(10 BYTE),
    d VARCHAR2(11 BYTE)
    ORGANIZATION EXTERNAL
    ( TYPE ORACLE_LOADER
    DEFAULT DIRECTORY dir_name
    ACCESS PARAMETERS
    ( records delimited by newline
    fields (
    a POSITION(*) CHAR(1),
    b POSITION(*) CHAR(2 ),
    c POSITION(*) CHAR(10 ),
    d POSITION(*) CHAR(11 )
    LOCATION (dir_name:'filename.txt')
    REJECT LIMIT UNLIMITED
    NOPARALLEL
    NOMONITORING;
    Regards,
    Simma....

Maybe you are looking for

  • Macbook pro won't turn on or charge. Help?

         I used my Macbook Pro last night and it was perfectly fine.  I turned it off, still with battery life.  This morning I tried turning it on, nothing happened.  So I tried plugging it in to charge to see what would happen.  Nothing.  The light of

  • Some videos not in sync with audio..

    some of the dvd's i put on my ipod have a problem..the audio is sometimes 6 seconds behind whats going on..how can i fix this when converting?

  • Ringtones off of the iPhone and into iTunes?

    As of yesterday I am now a Mac owner.  My PC crashed and I was unable to get any files off of it before it crashed.  I have about 30 unique ringtones on my iPhone that i made but I can't seem to get them off of my iPhone and on to my new Mac.  Help?

  • BUG:  Apex4/Anychart5 - memory leak?

    We are running into a pretty serious problem with resources. It seems that there is some kind of interaction between Apex and Anychart5 that is causing a pretty serious memory leak. For example, in one dashboard I am building, I have 9 charts on a pa

  • Set network speed & mode in Solaris 10

    Hi all, Can someone know how to change the network speed and mode in solaris 10 SPARC I tried with ndd -set , is this valid for Solaris 10 How can I check the speed and mode Regards, Hakim