Create a file

xiaoxiao2021-04-10  516

public boolean createFile (String _fileName, StringBuffer buf) {File file1 = new File (_fileName); if (file1.exists ()!) {try {file1.createNewFile (); FileOutputStream outfs = new FileOutputStream (file1); outfs.write (BUF.TOSTRING (). getBytes ());} catch (exception ex) {system.out.println (_filename "file create failure!"); return false;}} return true;

// Create a directory and associated class public String mkdirs (Object obj, String baseDdir) {Class m_class = obj.getClass (); StringBuffer _n = new StringBuffer (baseDdir); String _className = m_class.getName (); for (int k = 0; k <_classname.length (); k ) {char c = _ClassName.Charat (k); if (".". GetBytes () [0] == c) {_n.append ("");} Else {_n.append (c);

} File file1 = new file (_n.tostring ()); if (! File1.exists ()) {file1.mkdirs ();} return_n.tostring ();

}

// get the current packet based on the name of a public String getUpPackageName (Object obj, String prefix) {Class m_class = obj.getClass (); String packageName = m_class.getPackage () getName ();. Return packageName.substring (0 PackageName.lastIndexof (prefix) - 1);

} // Get the name of the current class public String getCurrentClassName (Object obj) {Class m_class = obj.getClass (); String packageName = m_class.getPackage () getName ();. String className = m_class.getName (); String [] _class = classname.split ("//."); system.out.println (_CLASS.LENGTH); for (int i = 0; i <_class.length; i ) {system.out.println (_CLASS [i] ); String Result = classname.substring (Classname.lastIndexof (packagename), classname.length ()); return results;}

转载请注明原文地址:https://www.9cbs.com/read-133305.html

New Post(0)