How to read and write Png and jpeg with  Alpha

Hi
I have trouble reading and writeing PNG and JPEGs that have an alpha channel (for transparency).
Reading works, if i use Toolkit.getImage() method, but works NOT if i use ImageIO.read() method.
Writing does NOT work using ImageIO.write()method. Instead i got a "java.lang.UnsupportedOperationException: Unsupported write variant!"
See Test class and commandline output below:
/****************START*****************************/
package de.multivisual.bodo.test;
import java.awt.*;
import java.awt.image.*;
import java.io.File;
import java.net.URL;
import java.util.Iterator;
import javax.imageio.*;
import javax.imageio.metadata.IIOMetadata;
import javax.imageio.stream.ImageInputStream;
import javax.imageio.stream.ImageOutputStream;
public class AlphaChannelTest implements ImageObserver {
  Toolkit toolkit;
  Image img;
  public AlphaChannelTest() {
    super();
    toolkit = Toolkit.getDefaultToolkit();
    URL url =
      AlphaChannelTest.class.getResource(
        "/de/multivisual/bodo/test/" + "alphatest.png");
    img = toolkit.getImage(url);
    try {
      ImageInputStream imageInput =
        ImageIO.createImageInputStream(url.openStream());
      Iterator it = ImageIO.getImageReaders(imageInput);
      ImageReader reader = null;
      while (it.hasNext()) {
        reader = (ImageReader) it.next();
        System.out.println(reader.toString());
      reader.setInput(imageInput);
      ImageReadParam param = reader.getDefaultReadParam();
      BufferedImage bimg = reader.read(0, param);
      SampleModel samMod = bimg.getSampleModel();
      ColorModel colMod =       bimg.getColorModel();
      String[] propNames = bimg.getPropertyNames();
      IIOMetadata meta = reader.getImageMetadata(0);
      System.err.println("\n*****test image that was read using new Jdk 1.4 ImageIO.read() method");
      alphaTest(bimg);
    } catch (Exception e) {
      //e.printStackTrace();
    if (img != null)
      toolkit.prepareImage(img, -1, -1, this);
    try {
      synchronized (this) {
        System.out.println("wait");
        this.wait();
    } catch (Exception e) {
      e.printStackTrace();
    System.out.println("end");
  public void alphaTest(BufferedImage bi) {
    Raster raster = bi.getData();
    float[] sample = null;
    System.out.println("raster :");
    for (int y = 0; y < raster.getHeight(); y++) {
      for (int x = 0; x < raster.getWidth(); x++) {
        sample = raster.getPixel(x, y, sample);
        System.out.print("(");
        for (int i = 0; i < sample.length; i++) {
          System.out.print(":" + sample);
System.out.print(")");
System.out.println();
Raster araster = bi.getAlphaRaster();
if (araster == null){
     System.err.println("there is no Alpha channel!!!!!!!!!");
     return ;
} else {
     System.out.println("Alpha channel found !");
float[] asample = null;
System.out.println("raster alpha:");
for (int y = 0; y < araster.getHeight(); y++) {
for (int x = 0; x < araster.getWidth(); x++) {
asample = araster.getPixel(x, y, asample);
for (int i = 0; i < asample.length; i++) {
System.out.print(" " + asample[i]);
System.out.println();
String format ="PNG";
System.out.println("##########Test Writing using new JDK1.4.1 ImageIO:");
Iterator writers = ImageIO.getImageWritersByFormatName(format);
ImageWriter writer = (ImageWriter) writers.next();
ImageWriteParam param = writer.getDefaultWriteParam();
ImageTypeSpecifier imTy = param.getDestinationType();
ImageTypeSpecifier imTySp =
ImageTypeSpecifier.createFromRenderedImage(bi);
param.setDestinationType(imTySp);
File f = new File("c:/tmp/myimage."+format);
try {
ImageOutputStream ios = ImageIO.createImageOutputStream(f);
writer.setOutput(ios);
writer.writeInsert(0, new IIOImage(bi, null, null), param);
} catch (Exception e) {
     System.err.println("could not write "+format+" file with alpha channel !");
e.printStackTrace();
public boolean imageUpdate(
Image img,
int infoflags,
int x,
int y,
int width,
int height) {
if ((toolkit.checkImage(img, -1, -1, null)
& (ImageObserver.HEIGHT | ImageObserver.WIDTH | ImageObserver.ALLBITS))
== 35) {
int iw = img.getWidth(this);
int ih = img.getHeight(this);
BufferedImage bi = new BufferedImage(iw, ih, BufferedImage.TYPE_4BYTE_ABGR);
Graphics2D big = bi.createGraphics();
big.drawImage(img, 0, 0, this);
System.err.println("+++++test image that was read using old Toolkti.getImage method");
alphaTest(bi);
synchronized (this) {
this.notifyAll();
return false;
return true; // image is not yet completely loaded into memory
public static void main(String[] args) {
//     BufferedImage image = new
// BufferedImage();
new AlphaChannelTest();
/*************************END********************/
The commandline looks like this:
[i]
com.sun.imageio.plugins.png.PNGImageReader@d1fa5
*****test image that was read using new Jdk 1.4 ImageIO.read() method
raster :
there is no Alpha channel!!!!!!!!!
wait
+++++test image that was read using old Toolkti.getImage method
raster :
Alpha channel found !
raster alpha:
##########Test Writing using new JDK1.4.1 ImageIO:
could not write PNG file with alpha channel !
java.lang.UnsupportedOperationException: Unsupported write variant!
     at javax.imageio.ImageWriter.unsupported(ImageWriter.java:600)
     at javax.imageio.ImageWriter.writeInsert(ImageWriter.java:973)
     at de.multivisual.bodo.test.AlphaChannelTest.alphaTest(AlphaChannelTest.java:113)
     at de.multivisual.bodo.test.AlphaChannelTest.imageUpdate(AlphaChannelTest.java:135)
     at sun.awt.image.ImageWatched.newInfo(ImageWatched.java:55)
     at sun.awt.image.ImageRepresentation.imageComplete(ImageRepresentation.java:636)
     at sun.awt.image.ImageDecoder.imageComplete(ImageDecoder.java:135)
     at sun.awt.image.PNGImageDecoder.produceImage(PNGImageDecoder.java:511)
     at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:257)
     at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:168)
     at sun.awt.image.ImageFetcher.run(ImageFetcher.java:136)
end

in between i found out that the my png and jpeg test images did not have an alpha channel, since the tool i used to create them, did not write the alpha channel to disk.
if i use png with alpha channel, then the read works correktly with ImageIO.read()
however the read problem still remains for gifs and the write does not work for gifs and neither for pngs.
whether jpegs can be read with alphachannel i don't know since i don't have a tool to create jpeg with alpha channel. (at least gimp and corel9 are not able to )
and it is not possible to write the previous read png with alpha channel back as and jpeg with alpha channel

Similar Messages

  • How to decoding and encoding PNG and GIF images?

    I could decode and encode JPEG images using following create functions which are in com.sun.image.codec.jpeg package.
    JPEGImageDecoder decoder = JPEGCodec          .createJPEGDecoder(inputStream);
    JPEGImageEncoder encoder = JPEGCodec                    .createJPEGEncoder(outputStream);
    But I dont know required package and functions to decode and encode PNG and GIF images. Please help me.

    Is the API that hard to follow?
    ImageIO.read( file/stream/url)
    ImageIO.write( image, format (e.g. PNG, GIF(1), JPEG), file/stream what have you)
    1) Not sure if Java supports GIF saving, it might if you install JAI, or Java 6.

  • How to read in a file and change the column attributes

    Hi,
    I'm new to java and i'm stuggling to find a way to read in a text file and perform calculations on the data, such as to normalise it.
    What in want to do is normalise the data by finding the greatest value in a column and then divide all the other values in the column with that value.
    I know how to read a file in and store each line in a vector but for this problem i think i need to store each column in an array, but i'm not sure how to do this.
    Can anyone help please?
    Thanks

    Hi,
    I'm new to java and i'm stuggling to find a way to
    read in a text file and perform calculations on the
    data, such as to normalise it.
    What in want to do is normalise the data by finding
    the greatest value in a column and then divide all
    the other values in the column with that value.
    I know how to read a file in and store each line in a
    vector but for this problem i think i need to store
    each column in an array, but i'm not sure how to do
    this.
    Can anyone help please?
    ThanksI think this should work but I wrote it out without completely thinking about it (hopefully to get things started).
    So if you had this:
    age height earnings
    0 2 100
    1 3 50
    2 1 0
    For the age column you'd take 2 as the largest and then divide 0 and 1 by two to get 0, .5.
    First build up test files that seperate the columns in different ways. With spaces, tabs, and the ASCI Control character for null ( I think it's 0 ). Your program should detect
    numbers and spaces, tabs control character, commas and periods (for money). Because numbers don't have spaces it should be easy to keep track of which column
    you're in.
    Store each line into a 3D String array with each index containing a String built up from the chars scanned in on each line, when a blank area is found followed by another
    number iterate the column index. When you come to the end of the line set column == 0 and row+1.
    private String[][][] test = new String[2][6][1];
    20     3      11      14      44       0
    4      5       7      80      91      49
    test[0][0][0] would be row 1 col 1 value 1 ((20))
    test[0][1][0] would be r1, c2, v1 ((3))
    test[1][0][0] would be r2, c1, v1 ((4))
    test[1][2][0] would be r2, c3, v1 ((7))
    test[1][5][0] would be r2, c6, v1 ((49))
    package source.Final;
    import javax.swing.*;
    import java.io.*;
    public class S7
         public static void main(String[] args)
              getContents();
              System.exit(0);
         public static void getContents()
              String lineSep = System.getProperty("line.separator");
              char c = ' ';
              int iterator = 0;
              int i = 0;
              int charNum = 1;
              int lineCount = 1;
             //declared here only to make visible to finally clause
             BufferedReader input = null;
             BufferedWriter out = null;
             try {
                         String line = null;
                          * This implementation reads / writes one line at a time
                          * using the buffered reader / writer Java classes.
                         input = new BufferedReader( new FileReader( "C:\\Scan file test\\Read\\test1.txt" ));
                           out = new BufferedWriter( new FileWriter( "C:\\Scan file test\\Read\\test2.txt" ));
                         //input = new BufferedReader( new FileReader( "C:\\Scan file test\\Read\\booked_policies1.txt" ));
                           //out = new BufferedWriter( new FileWriter( "C:\\Scan file test\\Write\\booked_policies1.txt" ));
                         //input = new BufferedReader( new FileReader( "C:\\Scan file test\\Read\\booked_policies2.txt" ));
                           //out = new BufferedWriter( new FileWriter( "C:\\Scan file test\\Write\\booked_policies2.txt" ));
                         //input = new BufferedReader( new FileReader( "C:\\Scan file test\\Read\\booked_policies3.txt" ));
                           //out = new BufferedWriter( new FileWriter( "C:\\Scan file test\\Write\\booked_policies3.txt" ));
                         out.write( "Character\tLine Number\tCharacter Number\tAscii Value" + lineSep );                     
                              while (( line = input.readLine()) != null)
                              i = 0;
                              charNum = 1;
                              iterator = 0;
                              while( i < line.length() )
                                               c = line.charAt(iterator);                                             
                                            if( (int)c == 0 || (int)c == 9 )
                                                 break;
                                            else if( c >= '[' && c <= '_')
                                                 {out.write( "["+c+"]\t\t"+"["+lineCount+"]\t\t"+"["+charNum+"]\t\t\t"+"["+(int)(c)+"]"+lineSep );}
                                            else if( c <  ' ' )// && (int)c != 0 && (int)c != 9  )
                                                 {out.write( "["+c+"]\t\t"+"["+lineCount+"]\t\t"+"["+charNum+"]\t\t\t"+"["+(int)(c)+"]"+lineSep );}
                                            else if( c >  ';' && c <= '@' && c != '=')
                                                 {out.write( "["+c+"]\t\t"+"["+lineCount+"]\t\t"+"["+charNum+"]\t\t\t"+"["+(int)(c)+"]"+lineSep );}
                                            else if( c >= '!' && c < '"' )
                                                 {out.write( "["+c+"]\t\t"+"["+lineCount+"]\t\t"+"["+charNum+"]\t\t\t"+"["+(int)(c)+"]"+lineSep );}
                                            else if( c >  'z' && c < '~' )
                                                 {out.write( "["+c+"]\t\t"+"["+lineCount+"]\t\t"+"["+charNum+"]\t\t\t"+"["+(int)(c)+"]"+lineSep );}
                                            else if( c == '%' )
                                                 {out.write( "["+c+"]\t\t"+"["+lineCount+"]\t\t"+"["+charNum+"]\t\t\t"+"["+(int)(c)+"]"+lineSep );}
                                            else if( c >  '~' )
                                                 {out.write( "["+c+"]\t\t"+"["+lineCount+"]\t\t"+"["+charNum+"]\t\t\t"+"["+(int)(c)+"]"+lineSep );}
                                            charNum += 1;
                                               iterator += 1;
                                               i++;
                                    lineCount += 1;
             catch (FileNotFoundException ex) {ex.printStackTrace();     System.out.println("File not found.");}
                 catch (IOException ex){ex.printStackTrace();               System.out.println("IO Error.");}
             finally{ try{ if( input != null ) input.close();                if( out != null ) out.close();}
                    catch (IOException ex){ex.printStackTrace();        System.out.println("IO Error #2.");}
        }

  • How to read some images from file system with webdynpro for abap?

    Hi,experts,
    I want to finish webdynpro for abap program to read some photos from file system. I may make MIMES in the webdynpro component and create photos in the MIMES, but my boss doesn't agree with me using this way. He wish me read these photos from file system.
    How to read some images from file system with webdynpro for abap?
    Thanks a lot!

    Hello Tao,
    The parameter
       icm/HTTP/file_access_<xx>
    may help you to access the pictures without any db-access.
    The following two links may help you to understand the other possibilities as well.
    The threads are covering BSP, but it should be useful for WebDynpro as well.
    /people/mark.finnern/blog/2003/09/23/bsp-programming-handling-of-non-html-documents
    http://help.sap.com/saphelp_sm40/helpdata/de/c4/87153a1a5b4c2de10000000a114084/content.htm
    Best regards
    Christian

  • Powershell script - how to read a registry hive and store the value in text file and then again read the text file to write the values back in registry

    Hi All,
    powershell script Method required to read a value from registry and then taking the backup of that values in some text file.
    For example the hive is
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path
    and under path i need to take back up  of values in some text file and then put some value in the registry after back is taken in text file.
    Also how to read the text file values so that we can again write to registry hive  back from the back up text file.
    Your help is much appreciated.
    Umeed4u

    I think you need to read this first:
    http://social.technet.microsoft.com/Forums/scriptcenter/en-US/a0def745-4831-4de0-a040-63b63e7be7ae/posting-guidelines?forum=ITCG
    Don't retire TechNet! -
    (Don't give up yet - 12,830+ strong and growing)

  • How to read the data file and write into the same file without a temp table

    Hi,
    I have a requirement as below:
    We are running lockbox process for several business, but for a few businesses we have requirement where in we receive a flat file in different format other than how the transmission format is defined.
    This is a 10.7 to 11.10 migration. In 10.7 the users are using a custom table into which they are first loading the raw data and writing a pl/sql validation on that and loading it into a new flat file and then running the lockbox process.
    But in 11.10 we want to restrict using temp table how can we achieve this.
    Can we read the file first and then do validations accordingly and then write to the same file and process the lockbox.
    Any inputs are highly appreciated.
    Thanks & Regards,
    Lakshmi Kalyan Vara Prasad.

    Hello Gurus,
    Let me tell you about my requirement clearly with an example.
    Problem:
    i am receiving a dat file from bank in below format
    105A371273020563007 07030415509174REF3178503 001367423860020015E129045
    in this detail 1 record starting from 38th character to next 15 characters is merchant reference number
    REF3178503 --- REF denotes it as Sales Order
    ACC denotes it as Customer No
    INV denotes it as Transaction Number
    based on this 15 characters......my validation comes.
    If i see REF i need to pick that complete record and then fill that record with the SO details as per my system and then submit the file for lockbox processing.
    In 10.7 they created a temporary table into which they are loading the data using a control file....once the data is loaded into the temporary table then they are doing a validation and updating the record exactly as required and then creating one another file and then submitting the file for lockbox processing.
    Where as in 11.10 they want to bypass these temporary tables and writing it into a different file.
    Can this be handled by writing a pl/sql procedure ??
    My findings:
    May be i am wrong.......but i think .......if we first get the data into ar_payments_interface_all table and then do the validations and then complete the lockbox process may help.
    Any suggestions from Oracle GURUS is highly appreciated.
    Thanks & Regards,
    Lakshmi Kalyan Vara Prasad.

  • How to read a text file and write text file

    Hello,
    I have a text file A look like this:
    0 0
    0 A B C
    1 B C D
    2 D G G
    10
    1 A R T
    2 T Y U
    3 G H J
    4 T H K
    20
    1 G H J
    2 G H J
    I want to always get rid of last letter and select only the first and last line and save it to another text file B. The output should like this
    0 A B
    2 D G
    1 A R
    4 T H
    1 G H
    2 G H
    I know how to read and write a text file, but how can I select the text when I am reading a text file. Can anyone give me an example?
    Thank you

    If the text file A look like that
    0 0
    0 3479563,41166 6756595,64723 78,31 1,#QNAN
    1 3479515,89803 6756588,20824 77,81 1,#QNAN
    2 3479502,91618 6756582,6984 77,94 1,#QNAN
    3 3479516,16334 6756507,11687 84,94 1,#QNAN
    4 3479519,14188 6756498,54413 85,67 1,#QNAN
    5 3479525,61721 6756493,89255 86,02 1,#QNAN
    6 3479649,5546 6756453,21824 89,57 1,#QNAN
    1 0
    0 3478762,36013 6755006,54907 54,8 1,#QNAN
    1 3478756,19538 6755078,16787 53,63 1,#QNAN
    2 0
    3 0
    N 0
    I want to read the line that before and after 1 0, 2 0, ...N 0 line to arraylist. I have programed the following code
    public ArrayList<String>save2;
    public BufferedWriter bufwriter;
    File writefile;
    String filepath, filecontent, read;
    String readStr = "" ;
    String[]temp = null;
    public String readfile(String path) {
    int i = 0;
    ArrayList<String> save = new ArrayList <String>();
    try {
    filepath = "D:\\thesis\\Material\\data\\CriticalNetwork\\test3.txt";
    File file = new File(filepath);
    FileReader fileread = new FileReader(file);
    BufferedReader bufread = new BufferedReader(fileread);
    this.read = null;
    // read text file and save each line content to arraylist
    while ((read = bufread.readLine()) != null ) {
    save.add(read);
    // split each arraylist[i] element by space and save it to String[]
    for(i=0; i< save.size();i++){
    this.temp = save.get(i).split(" ") ;
    // if String[] contain N 0 such as 0 0, 1 0, 2 0 then save its previous and next line from save arraylist to save2 arraylist
    if (temp.equals(i+"0")){
    this.save2.add(save.get(i));
    System.out.println(save2.get(i));
    } catch (Exception d) {
    System.out.println(d.getMessage());
    return readStr;
    My code has something wrong. It always printout null. Can anyone help me?
    Best Regards,
    Zhang

  • How to read from one file and write into another file?

    Hi,
    I am trying to read a File and write into another file.This is the code that i am using.But what happens is last line is only getting written..How to resolve this.the code is as follows,
    public String get() {
         FileReader fr;
         try {
              fr = new FileReader(f);
              String str;
              BufferedReader br = new BufferedReader(fr);
              try {
                   while((str= br.readLine())!=null){
                   generate=str;     
              } catch (IOException e1) {
                   e1.printStackTrace();
              } }catch (FileNotFoundException e) {
                   e.printStackTrace();
         return generate;
    where generate is a string declared globally.
    how to go about it?
    Thanks for your reply in advance

    If you want to copy files as fast as possible, without processing them (as the DOS "copy" or the Unix "cp" command), you can try the java.nio.channels package.
    import java.nio.*;
    import java.nio.channels.*;
    import java.io.*;
    import java.util.*;
    import java.text.*;
    class Kopy {
         * @param args [0] = source filename
         *        args [1] = destination filename
        public static void main(String[] args) throws Exception {
            if (args.length != 2) {
                System.err.println ("Syntax: java -cp . Kopy source destination");
                System.exit(1);
            File in = new File(args[0]);
            long fileLength = in.length();
            long t = System.currentTimeMillis();
            FileInputStream fis = new FileInputStream (in);
            FileOutputStream fos = new FileOutputStream (args[1]);
            FileChannel fci = fis.getChannel();
            FileChannel fco = fos.getChannel();
            fco.transferFrom(fci, 0, fileLength);
            fis.close();
            fos.close();
            t = System.currentTimeMillis() - t;
            NumberFormat nf = new DecimalFormat("#,##0.00");
            System.out.print (nf.format(fileLength/1024.0) + "kB copied");
            if (t > 0) {
                System.out.println (" in " + t + "ms: " + nf.format(fileLength / 1.024 / t) + " kB/s");
    }

  • How do I make Read and Write 10 Gold work with Firefox? I have the latest Firefox 10.0.1 but it keeps saying "Please upgrade your version of Mozilla Firefox. The minimum version supported by Read&Write is version 3.0."

    I just loaded Moxilla Firefox on my Windows 7 PC today and tried to use my Read and Write 10 Gold text help software but it just does not seem to work with this browser (works fine on Internet Explorer) as it keeps saying "Please upgrade your version of Mozilla Firefox.
    The minimum version supported by Read&Write is version 3.0." but this versions is higher than 3.0!

    We have a solution available for anyone needing to run Firefox 10 with Read&Write v10 Gold, please email us directly for this temporary resolution- [email protected]

  • How to  read from excel file and write it using implicit jsp out object

    our code is as below:Please give us proper solution.
    we are reading from Excel file and writing in dynamicaly generated Excel file.it is writing but not as original excel sheet.we are using response.setContentType and response.setHeader for generating pop up for saveing the original file in to dynamically generated Excel file.
    <%@ page contentType="application/vnd.ms-excel" %>
    <%     
         //String dLoadFile = (String)request.getParameter("jspname1");
         String dLoadFile = "c:/purge_trns_nav.xls" ;
         File f = new File(dLoadFile);
         //set the content type(can be excel/word/powerpoint etc..)
         response.setContentType ("application/msexcel");
         //get the file name
         String name = f.getName().substring(f.getName().lastIndexOf("/") + 1,f.getName().length());
         //set the header and also the Name by which user will be prompted to save
         response.setHeader ("Content-Disposition", "attachment;     filename="+name);
         //OPen an input stream to the file and post the file contents thru the
         //servlet output stream to the client m/c
              FileInputStream in = new FileInputStream(f);
              //ServletOutputStream outs = response.getOutputStream();
              int bit = 10;
              int i = 0;
              try {
                        while (bit >= 0) {
                        bit = in.read();
                        out.write(bit) ;
    } catch (IOException ioe) { ioe.printStackTrace(System.out); }
              out.flush();
    out.close();
    in.close();     
    %>

    If you want to copy files as fast as possible, without processing them (as the DOS "copy" or the Unix "cp" command), you can try the java.nio.channels package.
    import java.nio.*;
    import java.nio.channels.*;
    import java.io.*;
    import java.util.*;
    import java.text.*;
    class Kopy {
         * @param args [0] = source filename
         *        args [1] = destination filename
        public static void main(String[] args) throws Exception {
            if (args.length != 2) {
                System.err.println ("Syntax: java -cp . Kopy source destination");
                System.exit(1);
            File in = new File(args[0]);
            long fileLength = in.length();
            long t = System.currentTimeMillis();
            FileInputStream fis = new FileInputStream (in);
            FileOutputStream fos = new FileOutputStream (args[1]);
            FileChannel fci = fis.getChannel();
            FileChannel fco = fos.getChannel();
            fco.transferFrom(fci, 0, fileLength);
            fis.close();
            fos.close();
            t = System.currentTimeMillis() - t;
            NumberFormat nf = new DecimalFormat("#,##0.00");
            System.out.print (nf.format(fileLength/1024.0) + "kB copied");
            if (t > 0) {
                System.out.println (" in " + t + "ms: " + nf.format(fileLength / 1.024 / t) + " kB/s");
    }

  • How to read an html file and replace a text using text_io

    hi,
    i want ro read an html file using text_io and replace a particular text with a new text
    eg: i want to replace a text called "data.js" and with "maps.js"
    how do i do this?

    You have to write your own code to do that. TEXT_IO is just a low level text file interface.
    You need to read in all the text, save it in some internal format (array of varchar2's maybe or in the DB) and then perform a search on the text you have read in, find out where the instances of "data.js" are located and substitute them with "maps.js" After that you need to write to a new file and delete the old one. There is no way to search and replace inside the existing file (what's sometimes referred to as 'in-place' substitution).
    See the help section called About the TEXT_IO package for an overview of how it works and some code examples.

  • Rs232 read and write from pressure transducer with command.

    New to LabVIEW and have my first task. I have connected to a Setra pressure transducer via rs232 in Com port 4. I'm trying to track and log pressure over a given period of time. A command of "P" must be sent to the transducer for it to return a pressure reading. By searching, so far I have VISA open, close, read and write on my block diagram. I tried to create a constant from the VISA read resource name and connect it to COM4, but that did not work. Not sure how to accomplish my goal or how to wire everything up correctly. Any help for a beginner is appreciated.

    That error is due to some process already having exclusive rights to the port.  Do you have Hyperterminal or something else the could be using the COM port open?  Did you not close out the VISA reference during previous runs?
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • How to Read the "text file and csv file" through powershell Scripts

    Hi All
    i need to add a multiple users in a particular Group through powershell Script how to read the text and CSV files in powershell
    am completly new to Powershell scripts any one pls respond ASAP.with step by step process pls
    Regards:
    Rajeshreddy.k

    Hi Rajeshreddy.k,
    To add multiple users to one group, I wouldn't use a .csv file since the only value you need from a list is the users to be added.
    To start create a list of users that should be added to the group, import this list in a variable called $users, the group distinguishedName in a variable called $Group and simply call the ActiveDirectory cmdlet Add-GroupMember.
    $Users = Get-Content -Path 'C:\ListOfUsernames.txt'
    $Group = 'CN=MyGroup,OU=MyOrg,DC=domain,DC=lcl'
    Add-ADGroupMember -Identity $Group -Members $Users

  • Read and write from and to text file

     Hi All,
    I am trying to read some portion of a text file and make measurement and calculation with those numbers and write back to the same text file and also to a excel file. I need to create a 2 D  array of 20 by 20 from the text file values and write to front panel table and to text file. but I am having problem with it, obviously I am new to this. Please help me.  thanks much
    ~ Johnny

    Hi Lynn,
    the requirement is to move C1 and C2 to each position that is given in the text file in steps and percentage value.
    for example C1 has to go to first step (5%) and C2 has to go thru all steps, 5% to 95% , in 5 percent increment. 
    each 100 steps translates to 1 percent increment in the capacitor value.
    at the end, I need to enter the measured data (values of C1 for each step, vesus all values of C2 for all steps) and enter them at the bottom of the text file's table where it starts at : "IMPEDANCE_REAL in Ohmone line per C1 position, containing all values for the different C2 positions" and do the same for where it says "IMPEDANCE_IMAGINARY in Ohmone line per C1 position, containing all values for the different C2 positions"
    the reason I read the file twice, is that if it read it once, I couldn't connect it to spreadsheet string to array vi.
    as you can see, I also like to use the write to measurement file and build table express vi's to display the table on the front panel and save the data to ni data file format so later I convert it to excel  too.
    any thoughts?
    thanks for your help
    ~ Johnny
    Attachments:
    read from text2.vi ‏82 KB

  • How to read an ascii file and record data in a 2d array

    HI everyone,
    I have an experimental data file in ascii format. It contains 10 data sets.
    I'm trying to read the ascii file and record data in a 2d array for further analysis,
    but I still could not figure it out how to do it.
    Please help me to get this done.
    Here I have attaced the ascii file.
    -Sam
    Attachments:
    data.asc ‏123 KB
    2015-01-27_18-01-31_fourier_A2-F-abs.zip ‏728 KB

    Got it!
    Thank you very much !
    -Pamsath

Maybe you are looking for

  • How do I create a second itunes account?

    Is it possible to create a second account on itunes for my daughter with her separate ipod but using the same computer?  It seems like it automatically syncs. 

  • Adjustment of advance payment after adjusting AUC with Main Asset

    HI, My client is running KO88 without adjusting advance payment for Asset Purchase (AUC). Now this has led to accumulated advance payment with a huge amount. The purchase has taken place for more than 3 years. Kindly suggest, what is the correct step

  • Reconcilation account issue

    Hi all,            I have made a vendor payment and I entered the following entries. psky (25)   Vendor account  xxx (50)    outgoing interim payment account xxx After that i have passed an entry for transfering outgoing interim payment to main bank

  • Extension1 table in BAPI_OUTB_DELIVERY_CHANGE

    Hello all, As far as i understood, i have to fill this extension1 table to change the likp fields with this bapi. Is anyone has a sample code or an example for filling this table? There is only area for fields. Where are we going to put the values? A

  • Windows 7 64 bit recovery disk

    Hello, I bought ThinkPad T510 with 3 Gb of RAM and Windows 7 32 bit Professinal Russian (I'm from Russia). I'm going to upgrade RAM in my laptop, but I need to change OS from 32 bit to 64 bit. I know that it is legally possible - the license allows t