Program to read a file import java.util.Scanner; import java.io.File; public class FileRead { public static void main(String[] args) throws Exception { Scanner scan = new Scanner(new File(args[0])); while (scan.hasNext()) { System.out.println(scan.nextLine()); } } }
Posts
- Get link
- X
- Other Apps
Program to Write to a file import java.io.File; import java.io.PrintStream; public class FileWrite { public static void main(String[] args) throws Exception { PrintStream ps = new PrintStream(new File(args[0])); ps.println("My new file created by java I/O"); ps.print("I'm on new line."); ps.print("i'm still on same line."); //ps.close(); } }
- Get link
- X
- Other Apps
Program to Toggle contents of any file import java.io.File; import java.util.Scanner; import java.io.PrintStream; public class Toggle { public static void main(String[] args) throws Exception { File fileOld = new File(args[0]); File fileNew = new File("temp"); Scanner scan = new Scanner(fileOld); PrintStream ps = new PrintStream(fileNew); while (scan.hasNext()) { String content = scan.nextLine(); for (int i = 0; i < content.length(); i++) { if (content.charAt(i) >= 'a' && conten...
- Get link
- X
- Other Apps
/* * StringDemo.java * * Copyright 2013 Ajay Bhatia <ajay@dumb-box> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. * * */ public class StringDemo { public static void ma...
- Get link
- X
- Other Apps
/* * CircleAnimator.java * * Copyright 2013 Ajay Bhatia <ajay@dumb-box> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. * * */ import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JB...
- Get link
- X
- Other Apps
/* * PictureViewer.java * * Copyright 2013 Ajay Bhatia <ajay@dumb-box> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. * * */ import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JBu...
- Get link
- X
- Other Apps
/* * MoveText.java * * Copyright 2013 Ajay Bhatia <ajay@dumb-box> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. * * */ import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionP...