Linefeed writing into file.

Hi community!
I' am writing to file lines from internal table. But when I open the file, I see all data in one line. I need them a line for each structure.
Whats wrong?
Here is my code:
open dataset l_filename FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
loop at lt_str.
        transfer lt_str to l_filename.
endloop.
close dataset l_filename.

Hi,
To produce a line feed, use either the forward slash in the AT option of WRITE or ULINE or the NEW-LINE statement
Please check this link:
http://help.sap.com/saphelp_nw04/helpdata/en/9f/dba15335c111d1829f0000e829fbfe/content.htm
Regards.

Similar Messages

  • Writing into file in java card

    hi
    i am new to java card. What i need to do is to write a value in a particular file and read it everytime the mobile is switched on. Can anyone please guide me how do i create this file and read and write into it
    regds
    silverline

    Not really a SQL Developer question. You would be better over in the SQL and PL/SQL forum.
    You don't say what DBMS version you are using but if it is 10g or later, you don't need to restart the database to enable directories to write to.
    The utl_file_dir initialisation setting should no longer be used. Use CREATE DIRECTORY instead.

  • Problem in reading no. of files and writing into a single file

    Hi,
    Iam with Problem in reading no. of files and writing into a single file....
    Iam reading no. of files stored in local directory.......
    Iam able to read and print the data in files successfully....but while writing..only first file is being written...and the next files are not written in my output file...
    plz tell me my mistake....I hope Iam doing some mistake while writing into file...PLz help.....
    Basically my code structure is like this....
    import java.io.*;
    import java.util.regex.*;
    import java.util.*;
    import java.text.*;
    import org.apache.poi.poifs.filesystem.POIFSFileSystem;
    import org.apache.poi.hssf.usermodel.HSSFWorkbook;
    import org.apache.poi.hssf.usermodel.HSSFSheet;
    import org.apache.poi.hssf.usermodel.HSSFRow;
    import org.apache.poi.hssf.usermodel.HSSFCell;
    class Writing {
    public static void main(String args[]) throws Exception {
              FileOutputStream fileOut = new FileOutputStream("ServerResult.xls"); //my output file
              int counter = 1;
              File dir = new File("C:/Perform/ServerLogs");
              String[] children = dir.list();
              if( children == null)
                   System.out.println("The Directory mentioned does not exist");
              else {
                   for (int fileNo = 0; fileNo < children.length; fileNo++ ) {        //Files iteration starts
                        String filename = children[fileNo];
              File logFile = new File(filename);
    FileReader logFileReader = new FileReader(logFile);
    BufferedReader logReader = new BufferedReader(logFileReader);
    StringBuffer sBuf = new StringBuffer(5000);
              HSSFWorkbook wb = new HSSFWorkbook();          
              HSSFSheet sheet = wb.createSheet();
              HSSFRow rowTitle;
              HSSFRow rowReq;
              HSSFRow rowRes;
    String aLine = null;
    boolean skip = false;
    boolean readed = false;
    boolean initReq = false;
              boolean flag = false;
    long requestTime = 0;
    long responseTime = 0;
    long recdTime = 0;
    long sentTime = 0;
              long hasTime = 0;
              long presentTime = 0;
              int hasCalls = 0;
    Pattern startMessage = Pattern.compile("^<MESSAGE.*ID=\".*_"+args[0]+"\".*", Pattern.DOTALL);
    Pattern requestMessage = Pattern.compile("^<MESSAGE.*TS=\"(.*)\" CATEGORY=\"RequestMsg.\".*ID=\".*_"+args[0]+"\".*<ActName>(.*)</ActName>.*", Pattern.DOTALL);
    Pattern requestMessage1 = Pattern.compile("^<MESSAGE.*TS=\"(.*)\" CATEGORY=\"RequestMsg.\".*ID=\".*_"+args[0]+"\".*<Svc id=\"(.*)\">.*", Pattern.DOTALL);
    Pattern responseMessage = Pattern.compile("^<MESSAGE.*TS=\"(.*)\" CATEGORY=\"ResponseMsg\".*ID=\".*_"+args[0]+"\".*", Pattern.DOTALL);
    Pattern initMessage = Pattern.compile("^<MESSAGE.*TS=\"(.*)\" CATEGORY=\"HostConnInit\".*ID=\".*_"+args[0]+"\".*", Pattern.DOTALL);
    Pattern initResMessage = Pattern.compile("^<MESSAGE.*TS=\"(.*)\" CATEGORY=\"ResponseMsg\".*ID=\"null\".*", Pattern.DOTALL);
    Pattern initResIDMessage = Pattern.compile("^<MESSAGE.*TS=\"(.*)\" CATEGORY=\"ResponseMsg\".*ID=\"null\".*<IATA>"+args[0]+"</IATA>.*", Pattern.DOTALL);
              Pattern sentMessage = Pattern.compile("^<MESSAGE.*TS=\"(.*)\" CATEGORY=\"DCMsgSentInfo\".*ID=\".*_"+args[0]+"\".*", Pattern.DOTALL);
              Pattern rcvdMessage = Pattern.compile("^<MESSAGE.*TS=\"(.*)\" CATEGORY=\"DCMsgRcvdInfo\".*ID=\".*_"+args[0]+"\".*", Pattern.DOTALL);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
    DecimalFormat dcf = new DecimalFormat("########.##");
    String actName = "";
              if (fileNo ==0)
              rowTitle = sheet.createRow((short)0);
              rowTitle.createCell((short)0).setCellType(HSSFCell.CELL_TYPE_STRING);
              rowTitle.createCell((short)0).setCellValue("Req/Res");
              rowTitle.createCell((short)1).setCellType(HSSFCell.CELL_TYPE_STRING);
              rowTitle.createCell((short)1).setCellValue("Action");
              rowTitle.createCell((short)2).setCellType(HSSFCell.CELL_TYPE_STRING);
              rowTitle.createCell((short)2).setCellValue("Server Time(in ms)");
              rowTitle.createCell((short)3).setCellType(HSSFCell.CELL_TYPE_STRING);
              rowTitle.createCell((short)3).setCellValue("Request Vs Response Time in Server(in ms)");
              rowTitle.createCell((short)4).setCellType(HSSFCell.CELL_TYPE_STRING);
              rowTitle.createCell((short)4).setCellValue("Time Taken By HAS/HOST(in ms)");
              rowTitle.createCell((short)5).setCellType(HSSFCell.CELL_TYPE_STRING);
              rowTitle.createCell((short)5).setCellValue("No. of HAS calls");
              rowTitle.createCell((short)6).setCellType(HSSFCell.CELL_TYPE_STRING);
              rowTitle.createCell((short)6).setCellValue("Data Size");
              //wb.write(fileOut);
    while((aLine=logReader.readLine()) != null) {
    if(aLine.startsWith("<MESSAGE TYPE=\"EVENT\"")) {
    Matcher m = startMessage.matcher(aLine);
    if(m.find()) {
    sBuf.setLength(0);
    sBuf.append(aLine);
    skip = false;
    initReq = false;
    m = initMessage.matcher(aLine);
    if(m.find()) {
    initReq = true;
    } else {
    if(initReq) {
    m = initResMessage.matcher(aLine);
    if(m.find()) {
    sBuf.setLength(0);
    sBuf.append(aLine);
    skip = false;
    } else if(aLine.startsWith("</MESSAGE>")) {
    if(!skip) {
    sBuf.append(aLine);
    readed = true;
    } else if(!skip){
    sBuf.append(aLine);
    if(!skip && readed) {
    String tempStr = sBuf.toString();
    if(tempStr.length() > 0) {
    boolean reqMatched = false;
    Matcher m = null;
    if(initReq) {
    m = initMessage.matcher(tempStr);
    actName = "Intialization";
    } else {
    m = requestMessage.matcher(tempStr);
    String time = "";
    if(m.find()) {
    reqMatched = true;
    for (int i=1; i<=m.groupCount(); i++) {
    String groupStr = m.group(i);
    if(i == 1) {
    time = groupStr;
    } else if(i == 2) {
    actName = groupStr;
    } else if(!initReq){
    m = requestMessage1.matcher(tempStr);
    if(m.find()) {
    reqMatched = true;
    for (int i=1; i<=m.groupCount(); i++) {
    String groupStr = m.group(i);
    if(i == 1) {
    time = groupStr;
    } else if(i == 2) {
    actName = groupStr;
    if(time.length() > 0 ) {
    try{
    requestTime = sdf.parse(time).getTime();
    }catch(Exception ex){}
    System.out.println("Request,"+actName+","+time+",,,,"+dcf.format(((double)time.length()/1024.0))+"K");
                                  //bw.write("Request,"+actName+","+time+",,,,"+dcf.format(((double)time.length()/1024.0))+"K");
                                  String reqDataSize = dcf.format(((double)time.length()/1024.0))+"K" ;
                                  rowReq = sheet.createRow((short)counter);
                                       rowReq.createCell((short)0).setCellType(HSSFCell.CELL_TYPE_STRING);
                                       rowReq.createCell((short)0).setCellValue("Request");
                                       rowReq.createCell((short)1).setCellType(HSSFCell.CELL_TYPE_STRING);
                                       rowReq.createCell((short)1).setCellValue(actName);
                                       rowReq.createCell((short)2).setCellType(HSSFCell.CELL_TYPE_STRING);
                                       rowReq.createCell((short)2).setCellValue(time);
                                       rowReq.createCell((short)3).setCellType(HSSFCell.CELL_TYPE_STRING);
                                       rowReq.createCell((short)3).setCellValue("");
                                       rowReq.createCell((short)4).setCellType(HSSFCell.CELL_TYPE_STRING);
                                       rowReq.createCell((short)4).setCellValue("");
                                       rowReq.createCell((short)5).setCellType(HSSFCell.CELL_TYPE_STRING);
                                       rowReq.createCell((short)5).setCellValue("");
                                       rowReq.createCell((short)6).setCellType(HSSFCell.CELL_TYPE_STRING);
                                       rowReq.createCell((short)6).setCellValue(reqDataSize);
                                       counter = counter +1;
                                       System.out.println("counter is "+counter);
                             Matcher l = sentMessage.matcher(tempStr);
                             Matcher k = rcvdMessage.matcher(tempStr);
                   if(l.find()) {
                                            for (int i=1; i<=l.groupCount(); i++) {
         String groupStr2 = l.group(i);
    try{
    sentTime = sdf.parse(groupStr2).getTime();
    }catch(Exception ex){}
                        if(k.find())
                                                 for(int j=1;j<=k.groupCount(); j++) {
                                                 String groupStr1 = k.group(j);
                                                 try{
    recdTime = sdf.parse(groupStr1).getTime();
    }catch(Exception ex){}
                                                 presentTime = (recdTime - sentTime);
                                                 hasTime = hasTime + presentTime;
                                                 hasCalls = hasCalls +1;
    if(!reqMatched) {
    if(initReq) {
    m=initResIDMessage.matcher(tempStr);
    } else {
    m=responseMessage.matcher(tempStr);
    if(m.find()) {
    for (int i=1; i<=m.groupCount(); i++) {
    String groupStr = m.group(i);
    try{
    responseTime = sdf.parse(groupStr).getTime();
    }catch(Exception ex){}
                                                 String resDataSize = dcf.format(((double)tempStr.length()/1024.0))+"K" ;
                                                 rowRes = sheet.createRow((short)(counter));
                                                 rowRes.createCell((short)0).setCellType(HSSFCell.CELL_TYPE_STRING);
                                                 rowRes.createCell((short)0).setCellValue("Response");
                                                 rowRes.createCell((short)1).setCellType(HSSFCell.CELL_TYPE_STRING);
                                                 rowRes.createCell((short)1).setCellValue(actName);
                                                 rowRes.createCell((short)2).setCellType(HSSFCell.CELL_TYPE_STRING);
                                                 rowRes.createCell((short)2).setCellValue(groupStr);
                                                 rowRes.createCell((short)3).setCellType(HSSFCell.CELL_TYPE_NUMERIC);
                                                 rowRes.createCell((short)3).setCellValue((responseTime - requestTime));
                                                 rowRes.createCell((short)4).setCellType(HSSFCell.CELL_TYPE_NUMERIC);
                                                 rowRes.createCell((short)4).setCellValue(hasTime);
                                                 rowRes.createCell((short)5).setCellType(HSSFCell.CELL_TYPE_NUMERIC);
                                                 rowRes.createCell((short)5).setCellValue(hasCalls);
                                                 rowRes.createCell((short)6).setCellType(HSSFCell.CELL_TYPE_STRING);
                                                 rowRes.createCell((short)6).setCellValue(resDataSize);
                                                 hasTime = 0;
                                                 hasCalls = 0;
                                                 counter = counter + 1 ;
    sBuf.setLength(0);
    readed = false;
              wb.write(fileOut);
              } // End of for (int fileNo = 0; fileNo < children.length; fileNo++ )
    }     //End of else
              fileOut.close();
    } //End of public static void main
    } // End of Class

    First of all, use [code]-tags to make your code readable, please.
    I didn't do a complete inspection of your code (because it's too much and unreadable as it is) and I don't know POI, but creating a new HSSFWorkbook for each input file sounds fishy to me ... try re-using the workbook and just creating a new sheet in each iteration.

  • Very slow painting while reading and writing doubles into file

    for 15MB length file i = 7662080
    for 50MB length file i = 12414368
    Part of Code for writing into file follows like this:
    try{
    fos = new FileOutputStream("Angel.txt");
    File f = new File("Angel.txt");
         if(f.length() >=4)
         f.delete();
    fos = new FileOutputStream("Angel.txt");     
    dos = new DataOutputStream(new BufferedOutputStream(fos,1000000));
    int x=0;
    double y_last, y_new;
    for(int j=0 ;j<i ;j++)
    if(some condition)
    y_new = ....;
    try{
    //previously in vectors
    y_last = y_new;
    vect.add(new Line2D.Double(x, y_last, x, y_new)_;
    dos.writeDouble(y_new);
         }catch(Exception e){System.out.println(e);}
    dos.close();
    fos.close();
    x++;
    }catch(Exception excp){System.out.println(excp);}
    part of code for reading from file follows like this:
    public void paint(Graphics g)
    try{
         double y1, y2 =0;               
         Line2D.Double doub;
         raf = new RandomAccessFile("Angel.txt","r");
         dis = new DataInputStream(new BufferedInputStream(new FileInputStream(raf.getFD(),1000000)));
         raf.seek((rect.x*8));
         for (int i = 0/any value; (i < value as per choice); i++)
              g2.setStroke(new BasicStroke(0)); //2
              y1 = y2;
         y2 =dis.readDouble();
              doub=new Line2D.Double(i,y1,i,y2);
              g2.draw(doub);
    dis.close();
         raf.close();
    }catch(Exception excp){System.out.println(excp);}
    I tried using Object Streams but NotSerializable Exception is thrown as Line2D.Double objects
    are not serialized.
    Any idea to make reading and writing into file specially from MB files faster is appreciated.

    Why are you reading in the file in the paint method ?
    Create your data once before painting.
    I think you should explain what is your goal and what behavior you want.
    Denis

  • Writing into Excel file using PL/SQL and formatting the excel file

    Hi,
    I am writing into a excel file using PL/SQL and I want to make the first line bold on the excel. Also let me know if there are any other formatting options when writing into excel.
    Regards,
    -Anand

    I am writing into a excel file using PL/SQL
    Re: CSV into Oracle and Oracle into CSV
    check that thread or search in this forum...

  • How to insert new line char while writing bytes into file

    Hello Sir,
    Is it possible to insert the new line character in set of String variables and stored them into bytearray ,then finally write into File?
    This is the sample code which i tried:
                 File f = new File(messagesDir,"msg" + msgnum + ".txt");
                 FileOutputStream fout = new FileOutputStream(f);
                    String fromString = "From:    "+msg.getFrom()+"\n";
                    String toString = "To:     "+msg.getTo()+"\n";
                    String dateString = "Sent:    "+msg.getDate()+"\n";
                      String msgString =msg.getBody()+"\n";
                    String finalString=fromString+toString+dateString+msgString;
                    byte[] msgBytes = finalString.getBytes();
                    fout.write(msgBytes);
                 fout.close();in the above code , i tried to add the new line as "\n" in end of each string. but when i look into the generated files msg1.txt , it contains some junk char [] .
    please provide me the help
    regards
    venki

    but it has still shown the the junk char, its not able
    to create the new line in the created file i am afraid
    how am i going to get the solution?:(Do not be afraid dear sir. You are obviously using a windows operating system or a mac operating system. On windows a newline is "\r\n" not '\n', and on a mac a newline is '\r', not '\n'. If you make that correction, dear sir, your program will work.
    However, there is a better way. First, you probably want to buffer your output if you are going to write more than one time to the file, which will make writing to the file more efficient. In addition, when you buffer your output, you can use the newLine() method of the BufferedWriter object to insert a newline. The newline will be appropriate for the operating system that the program is running on. Here is an example:
    File f = new File("C:/TestData/atest.txt");
    BufferedWriter out = new BufferedWriter(new FileWriter(f) );
    String fromString = "From: Jane";
    out.write(fromString);
    //Not written to the file until enough data accumulates.
    //The data is stored in a buffer until then.
    out.newLine();
    String toString = "To: Dick";
    out.write(toString);
    out.newLine();
    String dateString = "Sent: October 27, 2006";
    out.write(dateString);
    out.newLine();
    out.close(); 
    //Causes any unwritten data to be flushed from
    //the buffer and written to the file.

  • \n is not working by the time writing text into file ...

    Hi,
    I am reading each line from file and writing into another file ...
    It is writing continously in the file even if i use \n for new line ...
    Why "\n" is not working by the time writing text into file ...
    Here is my code:
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class Test11{
    private BufferedReader data;
    private String line=null;
    private StringBuffer buf= new StringBuffer();
    private BufferedWriter thewriter=null;
    private File file=null;
    private FileReader fr=null;
    private String inputLocation="c:\\test14.txt";
    public Test11(){ }
    public void disp(){
    try {   
    file=new File(inputLocation);
    fr = new FileReader(file);
    data = new BufferedReader(fr);
    while ((line = data.readLine()) != null) {
    buf.append(line + "\n");
    String text=buf.toString();
    thewriter = new BufferedWriter(new FileWriter("c:\\test15.txt"));
    thewriter.write(text);
    buf=null;
    thewriter.close();
    } catch(IOException e) { System.out.println("error ==="+e ); }
    public static void main(String[] args) {
    Test11 t=new Test11();
    t.disp();
    System.out.println("all files are converted...");
    I used "\n" after reading each line .. i want output file also same as input file ... how do i break each line by the time writing into text file .. "\n" is working in word pad but now working in notepad ... in note pad i am getting some thing like rectangle insted of "\n" ....
    Any help please .....
    thanks.

    \n works just fine, and every text editor in the world except Notepad understands that it is supposed to be a line-ending character. You don't have a problem, except in your choice of text editor. If somebody is forcing you to use Notepad then you'll have to output "\r\n" instead.

  • OSB cluster --reading a writing into a file

    Dear All,
    I have a requirement in which my first OSB service s writing into a file(In a clustered environment).So in this case some of the files are being written in managed_server1 while some of the files are getting written in managed_server2.
    My second OSB service has to poll those files.Now as we know while polling,we have to define one target server(managed server).So this service will only be able to poll from one managed server.Is there any way it can poll from both the managed servers?

    Hello Deepthi,
    Can you please explian what is meant by shared storage as i am not aware of that.From shared storage, I meant common mounted/mapped file system.
    We have 2 managed servers on two different physical machines and we are using clustered environment.In this case you have two option -
    1. Use unique endpoint & mask combo for both the proxies and make sure that all the servers in the cluster have access to the staging directory of the polling manged server (by mounting/mapping the file system appropriately).
    2. Create a shared storage by mounting/mapping the file system for business services to put file and have a single proxy to poll that shared storage. Again all managed server need to have access to the staging directory of the polling manged server.
    You may like to refer metalink note ID 965135.1
    To understand how to achieve HA in this case, please refer -
    OSB10gR3:High-availbility of file protocol based proxy service
    Regards,
    Anuj

  • Why do I get a NI-488 error massage when writing into a file and at the same time copiyng this file with a backup softwarre like Easy2Sync?

    I have a small LabVIEW program which writes random numbers very fast into a ASCII-file. I want that file to be copied to a new position every 10 min. Therefor I use a backup/synchronisation software which is doing a copy operation every 10 min. It works fine a certian amount of time and after a while I get either an LabVIEW error (LabVIEW: Fiel already open: NI-488 Comand requieres GPIB Controller to be System controller) or an backup-software error (couldn´t open file...whatever). I´m guessing, it has something to do with file-access but I don´t know why?!? If I run the LabVIEW program and I copy and paste the random-number-file with the windows explorer very fast (pressing ctrl+v rapidly) while LabVIEW is still writing into this file, no error appears. Can sombody help me?
    LabVIEW 2011

    Hi Serdj,
    you don't get a GPIB error, the error number has just 2 different explanations...
    Well, you have two programs accessing the same file. One program just wants to make a copy, the other (LabView) is trying to write to the file. When copying a file that is written to you get inconsistent results! That's why one of both programs is complaining an error...
    You can't have write and read access at the same time! (But you can have more than one read access at the same time...)
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • ORA-48913: Writing into trace file failed

    Hi
    my OS: OUL5x64
    DB: 11.1.0.7
    receive this error in alert.log but could not figure out which parameter to increase.
    Can someone please help.
    Non critical error ORA-48913 caught while writing to trace file
    Error message: ORA-48913: Writing into trace file failed, file size limit [10485760] reached
    the suggestion:
    ORA-48913: Writing into trace file failed
    *Cause:An attempt was made to write into a trace file that exceeds the trace's file size limit
    *Action:increase the trace's file size limit.
    Thanks in advance.

    Hi ,
    I have one more doubt :
    ORACLE_SID=XXXX
    /XXXX/XX/ofaroot/XXXX/diag/rdbms/xxxx/XXXXX/trace
    Non critical error ORA-48913 caught while writing to file "trace /XXXX/XX/ofaroot/XXXX/diag/rdbms/xxxx/XXXXX/trace/XXXX_ora_8218.trc"
    Error message: ORA-48913: Writing into trace file failed, file size limit [10485760]everywhere its written to increase the parameter max_dump_file_size or to relocate the alert log, but as far as i understand ,
    is this because a trace file with the name XXXX_ora_8218.trc was getting generated with a greater size than the one defined in max_dump_file_size. Is this what happened ?
    Also , I am not able to find what directory does this parameter points to ? is it the trace directory or diag directory ?
    i checked select * from v$diag_info ,but i could not find any conclusion.
    Probably , on getting the above info , i will be able to decide where to move the alert.log to create space.

  • Problem in writing into the excel file using java code

    Hai ,
    I will be getting the data as a string and i am writing into the excel file. the problem is .if it has numeric values even now i will writing as a string data ,at this time i am getting the message in the excel file as "Number in the cell is formatted as text".
    I need to remove this thru my code..but i can write only as a string .
    To write in a excel file ,i used HSSFWorkbook.

    just check out
    http://www.andykhan.com/

  • Code for JProgressbar for monitoring  while writing into a files

    Could anybody help me in sample code to implement a JProgressbar while writing into a file.

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.lang.reflect.*; // for InvocationTargetException
    public class Test extends JApplet {
         private JProgressBar pb = new JProgressBar();
         public void init() {
              Container contentPane = getContentPane();
              final JButton startButton = new JButton("start");
              contentPane.setLayout(new FlowLayout());
              contentPane.add(startButton);
              contentPane.add(pb);
              startButton.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        GetInfoThread t = new GetInfoThread(Test.this);
                        t.start();
                        // this is okay because actionPerformed
                        // is called on the event dispatch thread
                        startButton.setEnabled(false);
         public JProgressBar getProgressBar() {
              return pb;
    class GetInfoThread extends Thread {
         Runnable getValue, setValue;
         int value, currentValue;
         public GetInfoThread(final Test applet) {
              getValue = new Runnable() {
                   public void run() {
                        JProgressBar pb = applet.getProgressBar();
                        currentValue = pb.getValue();
              setValue = new Runnable() {
                   public void run() {
                        JProgressBar pb = applet.getProgressBar();
                        pb.setValue(value);
         public void run() {
              while(true) {
                   try {
                        Thread.currentThread().sleep(500);
                        // This is okay because the getValue's run()
                        // is invoked on the event dispatch thread
                        value = (int)(Math.random() * 100);
                        try {
                             SwingUtilities.invokeAndWait(getValue);
                        catch(InvocationTargetException ite) {
                             ite.printStackTrace();
                        catch(InterruptedException ie) {
                             ie.printStackTrace();
                        if(currentValue != value) {
                             SwingUtilities.invokeLater(setValue);
                   catch(InterruptedException e) {
                        e.printStackTrace();
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.lang.reflect.*; // for InvocationTargetException
    public class Test extends JApplet {
         private JProgressBar pb = new JProgressBar();
         public void init() {
              Container contentPane = getContentPane();
              final JButton startButton = new JButton("start");
              contentPane.setLayout(new FlowLayout());
              contentPane.add(startButton);
              contentPane.add(pb);
              startButton.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        GetInfoThread t = new GetInfoThread(Test.this);
                        t.start();
                        // this is okay because actionPerformed
                        // is called on the event dispatch thread
                        startButton.setEnabled(false);
         public JProgressBar getProgressBar() {
              return pb;
    class GetInfoThread extends Thread {
         Runnable getValue, setValue;
         int value, currentValue;
         public GetInfoThread(final Test applet) {
              getValue = new Runnable() {
                   public void run() {
                        JProgressBar pb = applet.getProgressBar();
                        currentValue = pb.getValue();
              setValue = new Runnable() {
                   public void run() {
                        JProgressBar pb = applet.getProgressBar();
                        pb.setValue(value);
         public void run() {
              while(true) {
                   try {
                        Thread.currentThread().sleep(500);
                        // This is okay because the getValue's run()
                        // is invoked on the event dispatch thread
                        value = (int)(Math.random() * 100);
                        try {
                             SwingUtilities.invokeAndWait(getValue);
                        catch(InvocationTargetException ite) {
                             ite.printStackTrace();
                        catch(InterruptedException ie) {
                             ie.printStackTrace();
                        if(currentValue != value) {
                             SwingUtilities.invokeLater(setValue);
                   catch(InterruptedException e) {
                        e.printStackTrace();

  • Java Embedding for writing string into file

    Hi ,
    According to my requirement I need to create a file and write string data into file.
    This string data I am getting as a output of the partner link. Their is 5 string variable which I need to write in file .
    I want to use java Embedding activity .
    So plz provide me any solution or any link.

    Hi,
    Why would you want to do this with java embeding? Why not just use the assign activity to create/concatenate the string and then write it to a file with the file adapter?
    Andre

  • Writing java object into file

    Dear Experts,
    What is the best way to write java objects into file
    1. Using Object Output Stream
    or
    2.Using ByteArray OutputStream
    with Thanks
    Panneer

    Dear Experts,
    What is the best way to write java objects into file
    1. Using Object Output Stream
    or
    2.Using ByteArray OutputStream
    with Thanks
    PanneerWhat do you mean or? Because I would assume the contents of the byte array stream is coming from an ObjectOutputStream.
    Or do you mean to use some sort of buffering...

  • Access denied error while writing a file to the file system - myfileupload.saveas() throws system.unauthorizedexception

    hi,
    as part of my requirement , i have to perform read and  write  operations of  few files [ using the file upload control in my custom visual web part] and on submit button click.
    but while writing these files - with the help of  fileupload control - and when i use  myfileupload.saveas(mylocation);
    - i am saving these files into my D:\ drive of my server , where i am executing my code -, am getting access denied error.
    it throws system.unauthorizedexception.
    i have given full control on that folder where i was trying to store my attached files. and also  after following asp.net forums,
    i have added  iusr group added and performed all those steps such that, the file is saved in my D:\ drive.
    but unfortunately  that didnt happen.
    also
    a) i am trying the code with runwithelevatedprivileges(delegate() )  code
    b) shared the drive within the  d :drive where i want o save the files.
    c) given the full privieleges for the app pool identity- in my case , its
    network service.
    the  other strange thing is that, the same code works perfectly in  other machine, where the same sp, vs 2012  etc were installed .
    would like to know, any other changes/ steps i need to make it on this  server, where i am getting the  error.
    help is  appreciated!

    vishnuS1984 wrote:
    Hi Friends,
    I have gone through scores of examples and i am failing to understand the right thing to be done to copy a file from one directory to another. Here is my class...So let's see... C:\GetMe1 is a directory on your machine, right? And this is what you are doing with that directory:
    public static void copyFiles(File src, File dest) throws IOException
    // dest is a 'File' object but represents the C:\GetMe1 directory, right?
    fout = new FileOutputStream (dest);If it's a directory, where in your code are you appending the source file name to the path, before trying to open an output stream on it? You're not.
    BTW, this is awful:
    catch (IOException e)
    IOException wrapper = new IOException("copyFiles: Unable to copy file: " +
    src.getAbsolutePath() + "to" + dest.getAbsolutePath()+".");
    wrapper.initCause(e);
    wrapper.setStackTrace(e.getStackTrace());
    throw wrapper;
    }1) You're hiding the original IOException and replacing it with your own? For what good purpose?
    2) Even if you had a good reason to do that, this would be simpler and better:
    throw new IOException("your custom message goes here", e);
    rather than explicitly invokign initCause and setStackTrace. Yuck!

Maybe you are looking for

  • Ipad show a keyboard for password, old password no longer works

    I use my old iPad 1 (MC49LL) only as a great GPS in my motorhome. I use a new iPad Air for everything else. But somehow, the old unit no longer shows the regular touchpad for my password; it shows a keyboard. And my old password no longer works--the

  • Content won't display in iTunes

    So i have the new shuffle, and i have put about 80 songs on it and it works fine... BUT, when hooked up to iTunes, i wanted to check the contents of my new shuffle, maybe remove a couple of songs, but the content won't appear on the screen, although

  • Where clause sequence

    Hi select /some fields/ where clause field1=:b1 and field2=:b2 etc; Does sequence of field1 field2 in where cluase matters in reducing fetch time i.e select /some fields/ where field2=:b2 etc and field1=:b1 will be faster Prashant

  • Text formatting issues from MS Word 2011 to InDesign CS5.5

    Is there anyway to copy and paste text from MS Word 2011 into InDesign CS5.5 and have it retain the original formatting? Each time I try to copy and paste content from MS Word, even into a text box, all the bolding and italics are lost. I've tried to

  • I am trying to produce a formula that would allow an IF / THEN condition.

    I am trying to produce a formula that would allow an IF / THEN condition. I would like to be able to say that the selected cell would equal a specific cell if another cell had specific text entered in it..... i.e. In a sheet that contains cell from A