62,623
社区成员
发帖
与我相关
我的任务
分享public void createFile(String relativePath, String fileName, byte[] content)
throws AdaptorException{
FileAdaptor directory = new FileAdaptor();
directory.createDirectory(relativePath);
File file = new File(relativePath, fileName);
if (!file.exists()) {
try {
FileWriter resultFile = new FileWriter(file);
PrintWriter printFile = new PrintWriter(resultFile);
String strContent = new String(content); //这句我觉得该这么改
char[] ch=strContent.toCharArray();
for(int i=0;i<s.length();i++)
{
ch[i]=s.charAt(i);
}
String strContext="";
for(int i=0;i<ch.length;i++)
{
int a=(int)ch[i];
strContext=strContext+Integer.toBinaryString(a);
}
resultFile.write(strContent);
printFile.println(strContent);
resultFile.close();
System.out.println("Successful");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}