写了一个测试类,可以参考一下
@SpringBootTest
@RunWith(SpringRunner.class)
public class Test1 {
// 字符串输出到文件
@Test
public void test1() throws Exception {
InputStream inputStream = IOUtils.toInputStream("你好,哈哈哈哈");
FileOutputStream outputStream = new FileOutputStream(new File("d:/test2.txt"));
// 输出文件
IOUtils.copy(inputStream,outputStream);
inputStream.close();
outputStream.close();
}
}