Posts

Personalized File Manager (in development)

Summary - This application shows us recommendations of files by analyzing the previous search keywords and name of files opened. Development Language - This application is developed using java swing. Classes - FileInfo.java This class contains filename and number of times the file is opened by user. This data will be saved in database. OpenFile.java This class has methods to open selected file and also provide array of files in folder to display it. StoreData.java This class is used to store data into database. MainMethod.java Contains main method UserInterface.java Contains only UI methods and variables. Data saved in database - 1. File name 2. Number of times file opened Real time working of project - While StartUp - At the launch of this application the recommendations window will be filled with the filename suggestions according to the file open history. User Interface - There will be two windows. one to display list of files available in the targeted ...

Remove specific characters from file name if exists

There was many songs with the name of websites from which they were downloaded. i wanted to remove the name of websites from the name of song. Just for cleanness of name appearances in music player. I made java program for that. import java.io.File; public class StringRepeat { static File f[] = new File("c:/users/thesa/desktop/new folder/").listFiles(); static String str[] = new String[f.length]; public static void main(String agrs[]) { for (int i = 0; i < f.length; i++) { str[i] = (f[i].getName()); StringBuffer sb = new StringBuffer(str[i]); int x = (sb.lastIndexOf("www.djmaza.com")); if (x > 0) { System.out.println("File before renaming " + sb); sb.delete(x, x + 3); System.out.println("File after renaming " + sb); System.out.println("result from getparent " + f[i].getParent()); System.out.println("For loop end"); File renamed = new File(f[i].getParent() + ...

How to read Array using For loop

public class OpenFile { public static void main(String args[]) { int arr[] = new int [ 5 ]; for ( int i = 0 ; i < arr. length ; i++) { arr[i] = i; System. out .println(arr[i]); } } } outpu: 0 1 2 3 4

How to open any file using java

We need File and Desktop modules for this program import java.awt.*; import java.io.File; import java.io.IOException; public class OpenFile { public static void main(String args[]) { File f = new File( "filepath.exe" ); Desktop d = Desktop. getDesktop (); try { d.open(f); } catch (IOException i) { System. out .println(i); } } }

How to read text file using java

Read text file using BufferedReader class. import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; public class readtxt { public static void main(String args[]) { try { File f = new File( "d:/file.txt" ); BufferedReader bf = new BufferedReader( new FileReader(f)); while (bf.read() != - 1 ) { System. out .println(bf.readLine()); } } catch (IOException i) { System. out .println(i); } } }

Welcome

This is my first post here. You are welcome.