Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

copy xsl file

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi My friends,
How can I modify the following to copy any file endWith xsl on the desktop in stead of only copying data.xsl?
Your explanation is greatly appreciated.
import java.io.*;
import java.lang.*;
public class cfXSL {
public static void main(String[] args) {
try {
File inputFile = new
File("c:/windows/desktop/data.xsl");
String [] filenames = inputFile.list ();
File outputFile = new
File("c:/windows/desktop/WelcomeApplet3.java");
FileReader in = new FileReader(inputFile);
FileWriter out = new FileWriter(outputFile);
for (int i=0; i<filenames.length; i++)
{
if (filenames [i].endsWith (".xsl"))
{
LineNumberReader lnr = new LineNumberReader(in);
String s;
while ( (s = lnr.readLine()) != null ) {
System.out.println(lnr.getLineNumber() + "==> " + s );
out.write(s);
}
lnr.close();
in.close();
out.close();
}
}
}
catch (IOException ie) { System.out.println("input/output error"); }
}
}
 
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Please don't post the same question to more than one forum. This thread is now closed. All replies to the one in "IO and streams", please.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic