如何写入txt文件并将文本格式化为Java代码

时间:2019-07-18 11:26:12

标签: java format bufferedwriter

您好,StackOverFlow用户,我正在一个项目上,我需要能够将一些代码行写入文本文件。我已经知道如何使用Java将文本写入文件,但是当您在IDE中复制和粘贴代码时,我想对写入文件的行进行格式化。

@IBAction func handlePinchGestures(pinchGestureRecognizer: UIPinchGestureRecognizer) {
    if let view = pinchGestureRecognizer.view {
        switch pinchGestureRecognizer.state {
        case .changed:
            let pinchCenter = CGPoint(x: pinchGestureRecognizer.location(in: view).x - view.bounds.midX,
                                      y: pinchGestureRecognizer.location(in: view).y - view.bounds.midY)
            let transform = view.transform.translatedBy(x: pinchCenter.x, y: pinchCenter.y)
                .scaledBy(x: pinchGestureRecognizer.scale, y: pinchGestureRecognizer.scale)
                .translatedBy(x: -pinchCenter.x, y: -pinchCenter.y)
            view.transform = transform
            pinchGestureRecognizer.scale = 1
            imageLayerContainer.subviews.forEach({ (subview: UIView) -> Void in subview.setNeedsDisplay() })
        default:
            return
        }
    }
}

@IBAction func handlePanGesturesWithTwoFingers(panGestureRecognizer: UIPanGestureRecognizer) {
    let translation = panGestureRecognizer.translation(in: self.view)
    if let view = panGestureRecognizer.view {
        view.center = CGPoint(x:view.center.x + translation.x,
                              y:view.center.y + translation.y)
    }
    panGestureRecognizer.setTranslation(CGPoint.zero, in: self.view)
}

0 个答案:

没有答案