Example usage for java.io File File

List of usage examples for java.io File File

Introduction

In this page you can find the example usage for java.io File File.

Prototype

public File(URI uri) 

Source Link

Document

Creates a new File instance by converting the given file: URI into an abstract pathname.

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {
    BufferedImage bufferedImage = ImageIO.read(new File("a.jpg"));
    BufferedImage destinationBufferedImage = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
    Graphics2D g = destinationBufferedImage.createGraphics();
    AffineTransform at = AffineTransform.getScaleInstance(2, 2);
    g.drawRenderedImage(bufferedImage, at);
    ImageIO.write(destinationBufferedImage, "JPG", new File("b.jpg"));
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Sequence sequence = MidiSystem.getSequence(new File("midiaudiofile"));

    sequence = MidiSystem.getSequence(new URL("http://hostname/midiaudiofile"));

    // Create a sequencer for the sequence
    Sequencer sequencer = MidiSystem.getSequencer();
    sequencer.open();// w  w w. ja  va 2s .c  o  m
    sequencer.setSequence(sequence);

    double durationInSecs = sequencer.getMicrosecondLength() / 1000000.0;

}

From source file:Main.java

public static void main(String[] args) {
    File file = null;//www  . ja va 2  s  . c o  m
    WordExtractor extractor = null;
    try {

        file = new File("c:\\New.doc");
        FileInputStream fis = new FileInputStream(file.getAbsolutePath());
        HWPFDocument document = new HWPFDocument(fis);
        extractor = new WordExtractor(document);
        String[] fileData = extractor.getParagraphText();
        for (int i = 0; i < fileData.length; i++) {
            if (fileData[i] != null)
                System.out.println(fileData[i]);
        }
    } catch (Exception exep) {
    }
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Sequence sequence = MidiSystem.getSequence(new File("midifile"));

    // From URL/*from   www  .  ja va  2s .c o  m*/
    sequence = MidiSystem.getSequence(new URL("http://hostname/midifile"));

    // Create a sequencer for the sequence
    Sequencer sequencer = MidiSystem.getSequencer();
    sequencer.open();
    sequencer.setSequence(sequence);

    // Start playing
    sequencer.start();
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    copyDirectory(new File("c:\\"), new File("d:\\"));
}

From source file:MainClass.java

public static void main(String[] args) {
    try {/*from   w ww.jav a  2  s .  c om*/
        File aFile = new File("test.txt");

        FileOutputStream outputFile = null;
        outputFile = new FileOutputStream(aFile, true);
        FileChannel outChannel = outputFile.getChannel();

        ByteBuffer buf = ByteBuffer.allocate(200);

        buf.putInt(10).asCharBuffer().put("www.java2s.com");

        buf.position(10).flip();
        outChannel.write(buf);
        buf.clear();

        outputFile.close();

    } catch (Exception e) {
        e.printStackTrace();

    }

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    copyDirectory(new File("srcDir"), new File("dstDir"));
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    // From file//ww  w. ja v a  2 s .c  o  m
    Sequence sequence = MidiSystem.getSequence(new File("midiaudiofile"));

    // From URL
    // sequence = MidiSystem.getSequence(new
    // URL("http://hostname/midiaudiofile"));

    // Create a sequencer for the sequence
    Sequencer sequencer = MidiSystem.getSequencer();
    sequencer.open();
    sequencer.setSequence(sequence);

    // Start playing
    sequencer.start();
}

From source file:ImageConverterGIF.java

public static void main(String[] args) throws Exception {
    String imageFilePath = "C:/myBmp.bmp";
    String gifFilePath = "C:/myPic.gif";
    File inputFile = new File(imageFilePath);
    BufferedImage image = ImageIO.read(inputFile);
    File outputFile = new File(gifFilePath);
    ImageIO.write(image, "GIF", outputFile);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    // From file/*from ww w.j a va 2  s .  c  o m*/
    MidiFileFormat fformat = MidiSystem.getMidiFileFormat(new File("midifile"));

    // From URL
    //   fformat = MidiSystem.getMidiFileFormat(new URL("http://hostname/midifile"));

    // Get file format
    switch (fformat.getType()) {
    case 0:
        // mid
        break;
    case 1:
        // rmf
        break;
    }
}